HTML5 Audio Control Stop Button



Try the following code to add a stop button to your audio in HTML5:

function displayStopBtn() {
   var myPlayer = document.getElementsByTagName('audio')[0];
   myPlayer.pause();
   myPlayer.currentTime = 0;
}

You can also include jQuery:

$("#stopButton").click(function () {
   audio.pause();
   audio.currentTime = 0;
});
Updated on: 2020-01-28T10:20:06+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements