var audio = new Audio(); document.body.appendChild(audio); if (audio != null){ audio.src = "allofMe.mp3"; audio.autoplay = true; audio.controls = true; audio.onerror = function () { console.log("onerror: " + audio.error.code + " error msg: " + audio.error.message); }; audio.onpause = function () { console.log("onpause currentTime: " + audio.currentTime); console.log("onpause duration: " + audio.duration); }; audio.onended = function () { console.log("onended currentTime: "+ audio.currentTime); console.log("onended duration: " + audio.duration); }; }
还不清楚快播放完时会产生onpause事件。 在网上也没搜索到。有知道的,欢迎留言。 谢谢!