Pause Javascript Loop During Video -


given html5 video, possible create for- or while-loop not continue until video inside has ended? e.g., code below should play through 3 videos sequentially, not simultaneously.

<video id="video0">     <source src="video0.mp4"> </video> <video id="video1">     <source src="video1.mp4"> </video> <video id="video2">     <source src="video2.mp4"> </video> 

.

var i=0; while (i<3) {     document.getelementbyid('video'+i).play();     i++; } 

a loop not satisfy needs here, it's better listen events.

a list of events connected media-elements can found @ w3c page

so, in specific case, should you:

var playvideo = function(videoid){     var video = document.getelementbyid('video'+videoid);      if(video){              video.play();         //binding eventhandler event firing @ end of video         video.onended = function(e){             playvideo(videoid++);         }          /*          way of binding event-listener:         video.addeventlistener('ended',function(){             playvideo(videoid++);         });         */     } }  playvideo(0); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -