I've got a page with a few <audio>
elements in it. I get them in an array/collection/whatever, and want to listed for the "ended" event so as to try
and auto play the next one. I'm stuck. How to I id the next song to .play()
it? I think I'm about to blow my computer up.
Here's what I have...
var g = document.getElementsByTagName('audio');
for (var i = 0, len = g.length; i < len; i++){
(function(index){
// g[i].ended = function(){
// alert(index) ;
// };
//g[i].addEventListener("ended", holler(g[i]+1));
try{
g[i].addEventListener("ended", g[i+1].play());
} catch(e){
}
})(i);
}