문제

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