jquery - Loop HTML5 Videos on "ended" Event -
an html5 video plays. once has finished, script below called, incriments next video adds next line , begins playing it. how turn loop once second video finishes playing, append third video, , on?
<div> <video id="video0" autoplay> <source src="video0.mp4" /> </video> </div> .
var i=0 $('video'+i).on("ended", function() { i++; $(this).parent().append('<br /><video id="video' + + '" autoplay><source src="video' + + '.mp4" /></video>'); };
updated answer:
after re-reading question , seeing changes, here logic should you're asking...
var = 0; var numvideos = 5; var addvideo = function() { i++; var nextvideo=$('<video id="video' + + '" autoplay><source src="video' + + '.mp4" /></video>'); nextvideo.on('ended', addvideo); $(this).after('<br />').after(nextvideo); }; $('video0').on('ended', addvideo); original answer:
how adding loop attribute video tag? w3 resource
Comments
Post a Comment