solid-primitives icon indicating copy to clipboard operation
solid-primitives copied to clipboard

AudioState.COMPLETE is never used in primitive code

Open Vexcited opened this issue 9 months ago • 0 comments

Describe the bug

Hi ! I wrote this code earlier and found out it was never triggering :

const [audio, controls] = createAudio(track, () => state.playing, () => state.volume);

createEffect(() => {
  console.log(audio.state); // just for debug :')

  if (audio.state === AudioState.COMPLETE) { // this is never triggered !!
    const trackID = findSuitableTrack();
    console.info(`Playing track ${trackID} next.`);

    setState(prev => ({
      history: [...prev.history, prev.currentTrackID],
      currentTrackID: trackID
    }));
  }
});

When I looked through the enum, I thought that AudioState.COMPLETE would be perfect for my situation. Even though, it doesn't work, so I went through the primitive code to see what is happening under the hood.

In the whole file (https://github.com/solidjs-community/solid-primitives/blob/main/packages/audio/src/index.ts), AudioState.COMPLETE is NEVER used, it's just defined in the enum.

In the minimal reproduction link, you can see the state ends up to "paused" instead of "complete".

image

My question is: will there be any implementation concerning that in a near future ? Thanks you !

Minimal Reproduction Link

https://stackblitz.com/edit/github-p2hm8v?file=src%2FApp.tsx

Vexcited avatar May 11 '24 00:05 Vexcited