@@ -55,7 +55,8 @@ export const useSoundPlayer = (props: {
5555
5656 await initAudioContext . audioWorklet
5757 . addModule (
58- 'https://storage.googleapis.com/evi-react-sdk-assets/audio-worklet.js' ,
58+ //'https://storage.googleapis.com/evi-react-sdk-assets/audio-worklet.js',
59+ 'https://storage.googleapis.com/franc-worklet-test/worklet.js' ,
5960 )
6061 . catch ( ( e ) => {
6162 console . log ( e ) ;
@@ -104,16 +105,17 @@ export const useSoundPlayer = (props: {
104105 await audioContext . current . decodeAudioData ( arrayBuffer ) ;
105106
106107 const pcmData = audioBuffer . getChannelData ( 0 ) ;
108+ workletNode . current ?. port . postMessage ( { type : 'audio' , data : pcmData } ) ;
107109
108110 if ( gainNode . current ) {
109111 const now = audioContext . current . currentTime ;
110112 gainNode . current . gain . cancelScheduledValues ( now ) ;
111- const targetGain = isAudioMuted ? 0 : volume ;
112- gainNode . current . gain . setValueAtTime ( targetGain , now ) ;
113+ gainNode . current . gain . setValueAtTime (
114+ volume ,
115+ audioContext . current . currentTime ,
116+ ) ;
113117 }
114118
115- workletNode . current ?. port . postMessage ( { type : 'audio' , data : pcmData } ) ;
116-
117119 setIsPlaying ( true ) ;
118120 onPlayAudio . current ( message . id ) ;
119121 } catch ( e ) {
@@ -131,24 +133,18 @@ export const useSoundPlayer = (props: {
131133 }
132134
133135 const now = audioContext . current . currentTime ;
134-
135136 gainNode . current . gain . cancelScheduledValues ( now ) ;
136137 gainNode . current . gain . setValueAtTime ( gainNode . current . gain . value , now ) ;
137138 gainNode . current . gain . exponentialRampToValueAtTime (
138139 FADE_TARGET ,
139140 now + FADE_DURATION ,
140141 ) ;
141-
142- await new Promise ( ( resolve ) => {
143- setTimeout ( resolve , FADE_DURATION * 1000 ) ;
144- } ) ;
145-
146142 workletNode . current ?. port . postMessage ( { type } ) ;
147-
148- gainNode . current ?. gain . setValueAtTime (
149- 1.0 ,
150- audioContext . current ?. currentTime || 0 ,
151- ) ;
143+ /*await new Promise((resolve) => {
144+ setTimeout(() => {
145+ resolve(null);
146+ }, FADE_DURATION * 1000);
147+ });*/
152148 } , [ ] ) ;
153149
154150 const stopAll = useCallback ( async ( ) => {
0 commit comments