Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个音频标签,可以从网页 url 流式传输音乐。一旦歌曲超过 30 秒,我想让它运行一段代码。实现这一目标的最佳方法是什么?
timeupdate向控件引发的事件添加处理程序audio。在处理程序内部,查看控件的currentTime属性。
timeupdate
audio
currentTime
var audioControl = document.getElementById('myaudio'); audioControl.ontimeupdate = function () { if (audioControl.currentTime >= 30) { // do something } }