html5 audio currentTime doesn't work

前端 未结 2 1660
面向向阳花
面向向阳花 2020-12-21 06:19

I don\'t know why but it doesn\'t work. I have this:

function stop()
{
  audio.pause();
  audio.currentTime = 0;
}

When I change the value

相关标签:
2条回答
  • 2020-12-21 06:23

    This could be a browser compatibility issue. Unfortunately the HTML5 Audio API is still not very mature. Consider using a 'wrapper' such as soundmanager2.

    Also see older answer here

    0 讨论(0)
  • 2020-12-21 06:43

    I solved it:

    audio.pause();
    audio.src = audio.src;
    

    It reload the audio tag, and set currentTime to 0

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