最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is it possible to restrict forwarding in HTML5 video? - Stack Overflow

programmeradmin2浏览0评论

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
 |  Show 2 more ments

2 Answers 2

Reset to default 5

Well 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.

发布评论

评论列表(0)

  1. 暂无评论