Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
721 views
in Technique[技术] by (71.8m points)

javascript - html5 audio currentTime doesn't work

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 of currentTime to 0, nothing changes...that is, currentTime continues having the previous value.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I solved it:

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

It reload the audio tag, and set currentTime to 0


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...