質問

I have an audio tag that streams music from a web url. Once the song gets to over 30 seconds i want to get it to run a piece of code. Whats the best way to achieve this?

役に立ちましたか?

解決

Add a handler to the timeupdate event raised by the audio control. Inside the handler, look at the control's currentTime property.

var audioControl = document.getElementById('myaudio');
audioControl.ontimeupdate = function () {
    if (audioControl.currentTime >= 30) { 
        // do something
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top