HTML5 Video: Detect dragging of timeline

2019-09-17 03:58发布

问题:

I was wondering if there is a full-proof way of knowing when the user is dragging the timeline of an HTML5 video. Thus far I've been binding to timeUpdate, but it's unclear whether the currentTime is increasing due to a drag or simply the video playing. Thanks!

回答1:

I know that MediaElement.js which is a html5 video element implementation supports an event called 'seeked' which gives you what you want.

You could use that or look into the code to see what kind of logic they're using for detecting seeking.

Another way is that you can implement your own custom seek bar and if that's the case, you can just handle when the user drags the timeline scrubber to throw up a seeked event. The W3C has a document on how to implement the seeking.