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

Seeking fires a pause, play, and seek event.

Open belackriv opened this issue 8 years ago • 9 comments

This is probably intended, but is there anyway to determine from the pause/play event that these actions are happening due to a seek, and not due to a .play(), .pause(), or playPause() call?

belackriv avatar Feb 10 '16 22:02 belackriv

It's a bit of a bug. I think it shouldn't fire any events except seek when seeking.

katspaugh avatar Feb 21 '16 14:02 katspaugh

@belackriv Can't reproduce on v2. Is it still an issue in v1?

mspae avatar Oct 29 '17 14:10 mspae

It reproduces for me on v2. At least when the audio is playing.

vladflorescu avatar Jun 20 '18 14:06 vladflorescu

The guilty lines are:

Inside createBackend function:

https://github.com/katspaugh/wavesurfer.js/blob/cd5e3f2974032486d27c7ce6a605b708ce1c4d13/src/wavesurfer.js#L592-L594

and inside seekTo function:

https://github.com/katspaugh/wavesurfer.js/blob/cd5e3f2974032486d27c7ce6a605b708ce1c4d13/src/wavesurfer.js#L772-L775

https://github.com/katspaugh/wavesurfer.js/blob/cd5e3f2974032486d27c7ce6a605b708ce1c4d13/src/wavesurfer.js#L782-L784

vladflorescu avatar Jun 20 '18 14:06 vladflorescu

Seems like a very old issue but still happening with v4.2.0: seeking by clicking on the waveform pauses playback. This is perhaps intentional, but that was an issue for me.

To fix it — there may be a cleaner way (!) — I edited part of seekTo:

https://github.com/katspaugh/wavesurfer.js/blob/f62ad10492862e91729312925f1e8082c86d356f/src/webaudio.js#L650-L652

into

if(this.state === this.states[FINISHED]) {
   this.setState(PAUSED);
} else if(this.state === this.states[PLAYING]) {
   var _this42 = this;
   setTimeout(function() {
      _this42.play();
   }, 20);
}

The idea is, if we were playing, we wait a bit (20 ms) for the currentTime to be changed, etc... and then we resume playing.

Hope that helps...

egaudrain avatar Nov 18 '20 22:11 egaudrain

@egaudrain not sure if we need this timeout, tried it while playing and it doesn't pause when already playing.

Try it on the link below and see if you still experience the issue, using version 4.4.0: https://www.entonbiba.com/lab/ios2.html

entonbiba avatar Jan 25 '21 00:01 entonbiba

Sorry is there any remedy to this issue? It's really causing me a problem.

To clarify, the fact that skipping also triggers a play() event is causing me a real problem and I'd like it if skipping did not do this.

Gigamick avatar Feb 18 '21 15:02 Gigamick

what all events happens when the player is seeked from a 'paused' state in Youtube-Player?. I know that while playing a video , if we seek ,the events are (pause,play,buffer) in the prior said order.But that is not the case while seeking from a paused state.Is there anyway to determine such type of seek?.Or what happens when a user click on progress bar during a 'paused' state. Any help would be appreciated!.Thanks

hasanulsalah avatar May 20 '21 02:05 hasanulsalah

I also found that "finish" event fires "pause" after for some reason.

For me also, skipping is firing play, pause, and seek(which should be only one fired) events.

Adrian-Swifter avatar Dec 22 '21 01:12 Adrian-Swifter