我认为此播放列表的音乐不在播放中。但youtube播放器状态已启动。 所以按下暂停按钮并控制播放栏,可以正常播放。 我想从头开始做正常状态。
<!DOCTYPE html>
<html>
<body>
<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: '360',
width: '640',
events: {
'onReady': onPlayerReady,
}
});
}
function onPlayerReady(event) {
player.loadPlaylist({'listType' : 'playlist', 'list':'myplaylist','index' : '0','startSeconds':'0','suggestedQuality':'default' });
setTimeout(setShuffleFunction, 1000);
}
function setShuffleFunction(){
player.setShuffle(true);
}
</script>
</body>
</html>
添加捕获 Player State played (Pause button activate but music is not play)
答案 0 :(得分:0)
尝试
function onPlayerReady(event) {
player.loadPlaylist({'listType' : 'playlist', 'list':'myplaylist','index' : '0','startSeconds':'0','suggestedQuality':'default' });
setTimeout(setShuffleFunction, 1000);
player.play();
}