HTML audio Element how to replay?

前端 未结 8 1738
自闭症患者
自闭症患者 2020-12-16 22:52

I setup a HTML5 page, that include a node. The page will to playing a music(mp3 format),but it just play sound to end, and I use javascript to control audio element,even so

相关标签:
8条回答
  • 2020-12-16 23:09

    The suggestions above did not worked for me or where not applicable. I needed to replay sound when my code needed to do it.

    The following code worked (at least chrome):

    audioElement.setAttribute('src', audioSrc); audioElement.play();

    in other words, setting the src attribute again, then play() did the job

    0 讨论(0)
  • 2020-12-16 23:18

    In HTML5 you can just set audioElement.loop='true';

    0 讨论(0)
提交回复
热议问题