wavesurfer.js
wavesurfer.js copied to clipboard
Seeking fires a pause, play, and seek event.
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?
It's a bit of a bug. I think it shouldn't fire any events except seek
when seeking.
@belackriv Can't reproduce on v2. Is it still an issue in v1?
It reproduces for me on v2. At least when the audio is playing.
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
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 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
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.
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
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.