HTML5 音频控制停止按钮

javascriptweb developmentfront end scripts

尝试使用以下代码在 HTML5 中为您的音频添加停止按钮:

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

您还可以包含 jQuery:

$("#stopButton").click(function () {
   audio.pause();
   audio.currentTime = 0;
});

相关文章