我的页面中有多个youtube视频是基于日期DESC动态生成的。我想在视频结束后调用一个函数。我只想在一个视频中执行此操作(如最新的视频)。所有来自数据库的视频。 这是视频代码
<iframe width="560" height="315" id="player_video" src="https://www.youtube.com/embed/AEolY27i7yE?list=PLBFFEFD304803D5F5" frameborder="0" allowfullscreen></iframe>
我已为"player_video"
这是我的Js代码。
function onPlayerStateChange(event) {
switch(event.data) {
case YT.PlayerState.ENDED:
log('Video has ended.');
break;
case YT.PlayerState.PLAYING:
log('Video is playing.');
break;
case YT.PlayerState.PAUSED:
log('Video is paused.');
break;
case YT.PlayerState.BUFFERING:
log('Video is buffering.');
break;
case YT.PlayerState.CUED:
log('Video is cued.');
break;
default:
log('Unrecognized state.');
break;
}
}
new YT.Player('player_video', {
events: {
'onStateChange': onPlayerStateChange
}
});
但它不起作用。有什么建议吗?