You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When passing a HTMLAudioElement to createAudio, the state.player gets updated, however the original listeners aren't updated. (Also, any previous listeners aren't removed.)
Because src can be an instance of HTMLAudioPlayer, then the initial audio player is replaced by src, however the functions returned by makeAudioPlayer are still bound to the initial player. Idem for the handlers.
The text was updated successfully, but these errors were encountered:
yanickrochon
changed the title
Breaking audio controls when passing HTMLAudioElement as AudioSource
[audio] Breaking controls and state when passing HTMLAudioElement as AudioSource
Dec 6, 2024
My solution to this would be to implement #721 and remove HTMLAudioElement from AudioSource; do not allow src to be of type HTMLAudioElement.
This would allow this to work reactively:
const[audioSource,setAudioSource]=createSignal<AudioSource>();const[state,controls]=createAudio(audioSource);createEffect(()=>{constcontext=newAudioContext();constdestination=context.createMediaStreamDestination();constbufferSource=context.createBufferSource();bufferSource.buffer=audioBuffer;// an instance of AudioBufferbufferSource.connect(destination);setAudioSource(destination.streamsatisfiesMediaStream);});
Describe the bug
When passing a
HTMLAudioElement
tocreateAudio
, thestate.player
gets updated, however the original listeners aren't updated. (Also, any previous listeners aren't removed.)The following code is problematic:
Because
src
can be an instance ofHTMLAudioPlayer
, then the initial audio player is replaced bysrc
, however the functions returned bymakeAudioPlayer
are still bound to the initial player. Idem for the handlers.Minimal Reproduction Link
https://stackblitz.com/edit/github-8tkaus?file=src%2FApp.tsx
The text was updated successfully, but these errors were encountered: