Autoplay multiple audio files in sequence

Recently as I went through some of my old wordlists for test preparation, I noticed lots of <a href> tags on my cards that link to audio files, so I did some simple jquery tricks to make the cards audible, but there is still one problem remain, which is that I want for the first two audio files to autoplay.

Luckily, I did find the script that “sometimes” works, so with that being said, the script doesn’t do the whole job. In some rare cases, the first two audio files do autoplay, but in most cases it only make the first audio file autoplay, and I’m guessing there might be something wrong with the script.

Below is the script and here is a link to my test desk in case anyone wants to check that out.

jQuery(document).ready(function (){
var audioArray = document.getElementsByClassName('soundfiles');
var i = 0;
for (i = 0; i < audioArray.length - 1; ++i) {
    audioArray[i].addEventListener('ended', function(e){
        var currentSong =;
        var next = $(currentSong).nextAll('audio');
        if (next.length) $(next[0]).trigger('play');

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.