stopping html5 audio

前端 未结 3 1260
借酒劲吻你
借酒劲吻你 2021-01-21 23:41

How would I write a function that stops ALL instances of playing html5 audio in the DOM?

html5 audio

3条回答
  •  [愿得一人]
    2021-01-22 00:09

    first you have to set an id for your audio element

    in your js :

    var ply = document.getElementById('player');

    var oldSrc = ply.src;// just to remember the old source

    ply.src = "";// to stop the player you have to replace the source with nothing

提交回复
热议问题