The first video's ended => Start second video
The second video's ended => Start third video
The third video's ended => Start fourth video
The fourth video's ended => Start first video
It's just redefining the ended
event handler nonstop...
You could also use a variable starting at 0. increment it each time and set SRC to i%video_count
var i = 0;
var sources = ["http://www.a.com/blargh.m4v", "http://www.b.com/blargh.m4v"];
videoElement.addEventListener('ended', function(){
videoElement.src = sources[(++i)%sources.length];
videoElement.load();
videoElement.play();
}, false);
...The above code assumes the video is already playing onload, like your example