使用oncanplay?屬性定義音頻/視頻何時(shí)準(zhǔn)備好開(kāi)始播放。
示例
您可以嘗試運(yùn)行以下代碼來(lái)了解如何在媒體準(zhǔn)備開(kāi)始播放時(shí)執(zhí)行腳本 –
<!DOCTYPE html>
<html>
<body>
<video id = "myid" width = "320" height = "176" controls oncanplay="display()">
<source src = "/html5/foo.ogg" type = "video/ogg" />
<source src ="/html5/foo.mp4" type = "video/mp4" />
Your browser does not support the video element.
</video>
<script>
function display() {
alert("Video loaded!");
}
</script>
</body>
</html>
登錄后復(fù)制
以上就是當(dāng)媒體準(zhǔn)備好開(kāi)始播放時(shí),在HTML中執(zhí)行腳本的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!






