Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I want to play video in sequence.

Here is my code. It is running the first video in the playlist but not accepting the second video.

I checked by fetching the playlist. Its running perfectly fine. Please help me run the videos in sequece?
JavaScript
<head>
<script type="text/javascript">

var e=0;
  var playlist = [
  {
    //name: "Bleeding Love",
    file_name: "video/aw01.webm"
  },
  {
    //name: "Don't Forget",
    file_name: "video/teacch_640_1.webm"
  }
  ,
  {
   // name: "Bleeding Love",
    file_name: "video/aw01.webm"
  },
  {
   // name: "Don't Forget",
    file_name: "video/teacch_640_1.webm"
  }
]


function myEndedListener()
	 {	 
		myNewSrc();	
	 }

function myNewSrc() 
{
	
	while(e<playlist.length)>
	{
			 for (var k in playlist[e])
			 {    
				 var myVideo = document.getElementsByTagName('video')[0];
				 if(e!=0)
		{myVideo.removeEventListener('ended',myEndedListener(),false);}
				 myVideo.src=playlist[e][k];
				 myVideo.load();
				 myVideo.play();
				 e++;
				myVideo.addEventListener('ended',myEndedListener(),false);
				
			}
		  		
	   
	}
}

</script>
</head>
<body>
<div id="one">
<video width="960" height="540" controls="controls" onplay="this.play()" önclick="myEndedListener()">
</video></div>
</body>
</html>
Posted
Updated 12-Nov-11 19:28pm
v2

1 solution

 
Share this answer
 

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