📜  javascript 检测 youtube 视频何时结束 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:04.488000             🧑  作者: Mango

代码示例1
/*you will need to use the youtube iframe api*/
/*https://developers.google.com/youtube/iframe_api_reference */
var player = new YT.Player("video_holder_id",{
            width: '640',
            height: '390',
            videoId: "eXvLdB4zwsY",
            events: {
                'onReady': function(event){
                    console.log("video is ready");
                    event.target.playVideo();
                },
                'onStateChange': function(event){
                     if (event.data == YT.PlayerState.ENDED) {
                       //video has ended
                    }   
                }
    }
});