File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ title : 5.Play in silent
3
+ order : 5
4
+ ---
5
+
6
+ ``` jsx
7
+ import React , { Component } from ' react' ;
8
+ import ReactDOM from ' react-dom' ;
9
+ import ReactAudioSpectrum from ' react-audio-spectrum' ;
10
+
11
+ function App () {
12
+ return (
13
+ < div>
14
+ < audio id= " audio-element5"
15
+ src= " https://reader.guru/medias/How-Long-Will-I-Love-You.mp3"
16
+ autoPlay
17
+ crossOrigin= ' anonymous'
18
+ controls
19
+ >
20
+ < / audio>
21
+ < ReactAudioSpectrum
22
+ silent
23
+ id= " audio-canvas5"
24
+ audioId= {' audio-element5' }
25
+ / >
26
+ < / div>
27
+ );
28
+ }
29
+
30
+ ReactDOM .render ((
31
+ < App / >
32
+ ), mountNode);
33
+ ```
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-audio-spectrum" ,
3
- "version" : " 0.1.4 " ,
3
+ "version" : " 0.1.5 " ,
4
4
"description" : " a component for displaying audio spectrum" ,
5
5
"files" : [
6
6
" demo/" ,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ type ComponentProps = {
19
19
meterColor ?: string | ColorItem [ ] ,
20
20
meterCount ?: number ,
21
21
gap ?: number ,
22
+ silent ?: boolean ,
22
23
} ;
23
24
24
25
enum PLAY_STATUS {
@@ -39,6 +40,7 @@ export default function ReactAudioSpectrum(props: ComponentProps) {
39
40
] ,
40
41
gap= 10 ,
41
42
meterCount= 160 , meterWidth= 2 ,
43
+ silent= false
42
44
} = props ;
43
45
const _audioEleRef = useRef < HTMLElement > ( )
44
46
const _audioCanvasRef = useRef < HTMLCanvasElement > ( )
@@ -85,7 +87,9 @@ export default function ReactAudioSpectrum(props: ComponentProps) {
85
87
// @ts -ignore
86
88
_mediaEleSourceRef . current = _audioContextRef . current . createMediaElementSource ( audioEle )
87
89
_mediaEleSourceRef . current . connect ( _audioAnalyserRef . current )
88
- _mediaEleSourceRef . current . connect ( _audioContextRef . current . destination ) ;
90
+ if ( ! silent ) {
91
+ _mediaEleSourceRef . current . connect ( _audioContextRef . current . destination ) ;
92
+ }
89
93
}
90
94
}
91
95
You can’t perform that action at this time.
0 commit comments