How to disable seeking with HTML5 video tag ? -
i know not advisable. still need feature implemented. tried onseeking,onseeked media controller. nothing worked. there external libraries disable seeking. helpful if pointers on how go using custom controls.
the question quite old still relevant here solution:
var video = document.getelementbyid('video'); var supposedcurrenttime = 0; video.addeventlistener('timeupdate', function() { if (!video.seeking) { supposedcurrenttime = video.currenttime; } }); // prevent user seeking video.addeventlistener('seeking', function() { // guard agains infinite recursion: // user seeks, seeking fired, currenttime modified, seeking fired, current time modified, .... var delta = video.currenttime - supposedcurrenttime; if (math.abs(delta) > 0.01) { console.log("seeking disabled"); video.currenttime = supposedcurrenttime; } }); // delete following event handler if rewind not required video.addeventlistener('ended', function() { // reset state in order allow rewind supposedcurrenttime = 0; }); it player agnostic, works when default controls shown , cannot circumvented typing code in console.
Comments
Post a Comment