HTML5 音訊控制元件停止按鈕


嘗試以下程式碼,為你的 HTML5 音訊新增一個停止按鈕

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

你也可以包含 jQuery

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

更新於:2020 年 1 月 28 日

1K+ 瀏覽量

開啟你的職業生涯

完成課程,獲得認證

開始學習
廣告