wavesurfer.js icon indicating copy to clipboard operation
wavesurfer.js copied to clipboard

RegionsPlugin Chrome fires "region-out" event immediately on region.play() with MediaElement backend

Open jaredgei opened this issue 1 year ago • 5 comments

Bug description

When backend is set to MediaElement or not specified, the "region-out" event fires immediately when calling region.play(). It works fine in Safari, or when backend is set to WebAudio.

Environment

  • Browser: Chrome on Mac

Minimal code snippet

  const onPlaySegment = useCallback((idx: number) => {
    const region = regionsPlugin.current.regions[idx];
    region.play();
    regionsPlugin.current.once('region-out', () => { 
      // this fires before the region actually starts playing
      wavesurfer.current.pause();
    });
  }, [regionsPlugin, wavesurfer]);

I'd also really love a playOnce option in regions to just play the region from start to end so I don't need to manually stop the audio.

jaredgei avatar Sep 11 '24 15:09 jaredgei

Likely related to the browser briefly seeking backwards when starting playback.

katspaugh avatar Sep 11 '24 17:09 katspaugh

Same here!
The "region-out" event is fired immediately when region.play(). This is happening on Chrome with Mac, but works fine on Firefox.

Any idea how to hack it on Chrome? Any idea if this will be solved soon?

Thanks! I love this library 👍

MarcRibera avatar Sep 17 '24 12:09 MarcRibera

Same here! The "region-out" event is fired immediately when region.play(). This is happening on Chrome with Mac, but works fine on Firefox.

Any idea how to hack it on Chrome? Any idea if this will be solved soon?

Thanks! I love this library 👍

Try setting backend: WebAudio in the wavesurfer settings, that's working for me for now!

jaredgei avatar Sep 17 '24 13:09 jaredgei

Having Same issue! The "region-out" event is fired immediately when region.play(). I have tried by setting backend: WebAudio still having same error.

kinjal017 avatar Sep 20 '24 12:09 kinjal017

@jaredgei It works for me too! Thanks 👍

MarcRibera avatar Sep 28 '24 21:09 MarcRibera