HTML5 audio control stop button

JavascriptWeb DevelopmentFront End Scripts

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;
});
raja
Published on 10-Apr-2018 09:02:40
Advertisements