我正在使用 YouTube API,我正在尝试在我的视频结束时设置一个 onStateChange 以随机播放我的播放列表并从 0 开始......这就是我到目前为止所得到的
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
player.loadPlaylist({'listType': 'playlist', 'list': 'PLF776D41D8211F340','index': '0','startSeconds': '0','suggestedQuality': 'hd720'});
}
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && done == false) {
player.setShuffle(true);
player.playVideoAt(0);
done = true;
}else if (event.data == YT.PlayerState.ENDED && done == true) {
player.setShuffle(true);
player.playVideoAt(0);
done = false;
}
}
我在这里做错了什么?