Setting the currentTime of an <audio> tag not working?

前端 未结 6 665
生来不讨喜
生来不讨喜 2020-12-31 07:41

I have this audio tag playing in the background, and I\'m able to store the progress in seconds to a cookie. But in no way I\'m able to start the audio from that cookie. (fo

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-31 08:24

    This works for me.

    if (!isNaN(audio.duration)) {
        audio.currentTime = 0;
    }
    

    Hope it helps!

提交回复
热议问题