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

javascript - Workaround for <video> loop attribute in Firefox - Stack Overflow

programmeradmin0浏览0评论

Does anyone know of a workaround (JavaScript, I'd guess) for looping HTML5 <video> elements in Firefox. The loop attribute isn't currently supported in Firefox.

Does anyone know of a workaround (JavaScript, I'd guess) for looping HTML5 <video> elements in Firefox. The loop attribute isn't currently supported in Firefox.

Share Improve this question asked Sep 10, 2011 at 22:26 ryanoshearyanoshea 2,4791 gold badge16 silver badges15 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

Please do not abuse jQuery like this!! You don't need a massive library to bind a simple listener! Use this:

 document.getElementById('video').addEventListener("ended", function(){this.play();});

This will trigger when the video ends. The anonymous function will then be ran. "this" refers to the video element by which we execute the play function on causing the video to re-play.

Shame on Firefox for letting this bug go unfixed for so long!

None of the answers here worked for me with Firefox on OS X.

My solution was to add loop="loop" to the video tag. Omitting the ="loop" caused the video not to loop.

<video src="myvid.mp4" loop="loop"></video>

Don't have any videos to test with but found a solution on the firefox support forums using jQuery that you can try out:

$("#yourID").bind('ended', function(){ 
  this.play();
});

http://support.mozilla./en-US/questions/747220

A JQuery workaround as nabbed from Mozilla's site worked for me ( http://support.mozilla./en-US/questions/747220 ):

$("#yourID").bind('ended', function(){
this.play();
});
发布评论

评论列表(0)

  1. 暂无评论