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

Does anyone know of a workaround (JavaScript, I'd guess) for looping HTML5 <video> elements

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();
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744040324a4548190.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信