如何使用该loadPlaylist
选项以自动播放下一个视频?我的代码是这样的,但它不起作用,无法播放视频:
<div id="player"></div>
<script>
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
loadPlaylist:{
listType:'playlist',
list:['4Ivdp8kj_0U','4MJRS-cLozU'],
index:parseInt(0),
suggestedQuality:'small'
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
event.target.playVideo();
}
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
// setTimeout(stopVideo, 60000);
done = true;
}
}
function stopVideo() {
player.stopVideo();
}
</script>
我想实现这个例子的效果: http ://www.youtube.com/watch?v=0DdCoNbbRvQ&list=RD02_VTY8ftr1vY
非常感谢。