html5 video 監聽播放結束. 最好獲取html標簽而不是id。


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
      <video id="media" src="http://200021507.vod.myqcloud.com/200021507_8a9451f48f8711e6b4f5452017aa0113.f30.mp4" controls width="400px" heigt="400px"></video>  
<script>



// var md=document.getElementsByName("video");
var md=document.getElementsByTagName("video")[0];
    if(md.ended){
        console.log("結束");
    }
    md.addEventListener("ended",function(){
         console.log("結束");
    })
</script>

</body>
</html>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM