I'm trying to use this to play three mp3 files one after another. I'm newbe on javascript, but after reading few answers from SO i wrote this:
var audioFile = new Array("3727.mp3","3706.mp3","3730.mp3");
var audio = new Array;
for (i=0; i<audioFile.length; i++) {
audio[i] = new Audio(audioFile[i]);
audio[i].load();
}
for (i=0; i<audioFile.length-1; i++) {
audio[i].addEventListener("ended", function() {
audio[i+1].play();
});
}
audio[0].play();
But it plays only first file. Can anyone clarify why?
Regards!
Aucun commentaire:
Enregistrer un commentaire