I am trying to restrict forwarding in my HTML5 video element. But is there any possibility to do this.
I want to restrict the fast forwarding of the video, However backward navigation should be allowed.
Thanks.
I am trying to restrict forwarding in my HTML5 video element. But is there any possibility to do this.
I want to restrict the fast forwarding of the video, However backward navigation should be allowed.
Thanks.
Share Improve this question edited Feb 28, 2012 at 14:47 Tushar Ahirrao asked Feb 28, 2012 at 14:16 Tushar AhirraoTushar Ahirrao 13.2k18 gold badges66 silver badges98 bronze badges 7- 1 What exactly do you mean by forwarding? – Ian Devlin Commented Feb 28, 2012 at 14:27
- @lan Devlin..I want to restrict the forward navigation of the video, However backward navigation should be allowed. – Tushar Ahirrao Commented Feb 28, 2012 at 14:30
- @IanDevlin: fast forward – jgauffin Commented Feb 28, 2012 at 14:43
- @lanDevlin... Yes fast forward... – Tushar Ahirrao Commented Feb 28, 2012 at 14:47
- Can you include the HTML you are using to show the video ... – Manse Commented Feb 28, 2012 at 14:53
2 Answers
Reset to default 5Well it's not perfect but you could always save the current timestamp everytime and pare with that. If it goes after the current timestamp, just reset it back to the old one.
var video = document.getElementsByTagName("video")[0];
var previousTime = 0;
video.addEventListener("timeupdate", function(event) {
previousTime = video.currentTime;
});
video.addEventListener("seeking", function(event) {
if (video.currentTime > previousTime)
video.currentTime = previousTime;
});
I tried to find a way to cancel the seeking events for a smoother result but couldn't get it to work. If anyone has any insight on how to cancel those, would be much appreciated.
Don't include a controls
attribute and then implement your own UI. You can create a fast forward button that does whatever you like … or not include one at all.