How to play HTML <audio> blocks one by one with no pops and clicks?

JavascriptWeb DevelopmentFront End Scripts

To play HTML <audio>blocks one by one, use the following HTML first −

<audio id = "one">
   <source src = "new1.mp3" type = "audio/mp3">
</audio >
<audio id = "two">
   <source src = "new2.mp3" type = "audio/mp3">
</audio >

The following is what you need to do to play audio one by one −

var one = document.getElementById('one');
one.onended = function() {
   document.getElementById('two').play();
}
one.play();
raja
Published on 06-Apr-2018 15:13:56
Advertisements