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



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();
Updated on: 2020-06-25T07:48:32+05:30

82 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements