How to play HTML


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: 25-Jun-2020

42 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements