I need help finding a code that allows me to autoplay a second audio clip after the first audio clip is done.
On 'end' event of the 1st audio clip call a function that plays second audio clip.
OR
You can change the src of audio file on end of the 1st audio, and then start the play function again. Check the below code:
HTML:
JS:
var audio = document.getElementById("player");
audio.addEventListener("ended", function() {
audio.src = "nextAudio.mp3";
audio.play();
});
I was able to implement the code into the html but I wasn't able to get the results.
This is what it looks before I added anything to it. What would be my best choice to do?
If you are using the above html then use below JS:
jQuery(".qmedia:eq(0)").on("ended",function(){
document.getElementsByClassName('qmedia')[2].play()
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.