Answer the question
In order to leave comments, you need to log in
How do I make a playlist start playing another track when one track ends?
There is a playlist consisting of audio elements, I create a collection of them, assign an eventListener by iteration:
var audios = document.getElementsByTagName('audio'), i = 0, len = audios.length;
for (; i < len; i++) {
audios[i].addEventListener('ended', function() {
audios[i + 1].playing();
});
}
but this code doesn't work, no event handler is added. What could be wrong here? Or should the task be handled in some other way? Answer the question
In order to leave comments, you need to log in
for (; i < len; i++)
You have before ; it must be declared from which number i to start the loop.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question