ryanoshea
ryanoshea

Reputation: 2479

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 loop attribute isn't currently supported in Firefox.

Upvotes: 2

Views: 4024

Answers (4)

Hawk
Hawk

Reputation: 561

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!

Upvotes: 5

Janne Annala
Janne Annala

Reputation: 28687

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>

Upvotes: 2

mal-wan
mal-wan

Reputation: 4476

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

Upvotes: 1

Andres I Perez
Andres I Perez

Reputation: 75379

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

Upvotes: 1

Related Questions