admin 管理员组

文章数量: 1086019

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

本文标签: javascriptWorkaround for ltvideogt loop attribute in FirefoxStack Overflow