You can play multiple videos one after another in a loop using HTML5 and javascript.
Using “ended” event you can detect when a HTML5 <video> element has finished playing.
Steps:
Place the HTML5 video tag inside the body.You can also add “autoplay” attributes to start playing automatically.
<video controls id="myVideo" > </video>
Then you can store the videos using an array.
var videoSource = new Array(); videoSource[0]='video/video.m4v'; videoSource[1]='video/BigBuck.m4v'; var videoCount = videoSource.length;
You can add the first video src by using Javascript.
document.getElementById("myVideo").setAttribute("src",videoSource[0]); Create a function to load and play the videos. function videoPlay(videoNum) { document.getElementById("myVideo").setAttribute("src",videoSource[videoNum]); document.getElementById("myVideo").load(); document.getElementById("myVideo").play(); }
Then you can add an event listener with ‘ended’ as first parameter which detects the completion of the event.
document.getElementById('myVideo').addEventListener('ended',myHandler,false); function myHandler() { i++; if(i == (videoCount-1)){ i = 0; videoPlay(i); } else{ videoPlay(i); } }