Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a code which displays multiple text with timeout of 2000. The same i have to implement for HTML5 videos. How could i achieve this?
The Video Attribute [src] should get changed every 2000[time] to play a next video.

XML
<html>
  <body>



   <span id="myVid" />

 <!--     <video controls autoplay="autoplay">
          <source src="myVid" />
      </video>-->

  <script id="jsbin-javascript">
var videos = [
    "dictionary/1.mp4",
    "dictionary/2.mp4",

];
videoPlayer = document.getElementById("myVid");
function playArray(index,ele,array,listener){
    //e.removeEventListener(listener?listener:0);
    ele.innerHTML = array[index];
    //e.load();
   //le.play();

    index++;
    if(index>=array.length){
        index=0;
    }

    setTimeout(function(){
        playArray(index,ele,array,listener);
    },2000);
}
playArray(0,document.getElementById("myVid"),videos);
</script>
</body>
</html>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900