Workaround for <video> loop attribute in Firefox
Does anyone know of a workaround (JavaScript, I'd guess) for looping HTML5 <video>
elements in Firefox. The lo开发者_如何学编程op
attribute isn't currently supported in Firefox.
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.com/en-US/questions/747220
A JQuery workaround as nabbed from Mozilla's site worked for me ( http://support.mozilla.com/en-US/questions/747220 ):
$("#yourID").bind('ended', function(){
this.play();
});
精彩评论