Given HTML5 video, is it possible to create a for- or while-loop that will not continue until the video inside it has ended? E.g., the code below should play through the three 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 will not satisfy your needs here, it’s better that you listen for Events.
A list of all events that are connected with Media-Elements can be found at the W3C Page
So, in your specific case, something like this should help you: