我一直在尝试设置我的 youtube api 来随机播放我的播放列表,但顺序始终相同......
这是我从 https://developers.google.com/youtube/iframe_api_reference#setShuffle获取代码的链接
我说的对吗?
这是我下面的代码
<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',
events: {
'onReady': onPlayerReady
}
});
}
function onPlayerReady(event) {
player.loadPlaylist({'listType': 'playlist', 'list': 'PLF776D41D8211F340','index': '0','startSeconds': '0','suggestedQuality': 'hd720'});
player.setShuffle({'shufflePlaylist' : 1});
}
</script>
我尝试将 shufflePlaylist 设置为“true”,我尝试过 cueplaylist 而不是 loadplaylist,我什至尝试将 shufflePlaylist 放入加载播放列表中......没有任何东西被洗牌。
我对此进行了调查,发现这是 API 的问题,但那是 2 年前的事了,有没有解决这个问题的方法?
以下是我尝试过但没有奏效的方法
player.setShuffle(1);
player.setShuffle('1');
player.setShuffle(true);
player.setShuffle('true');
player.setShuffle({'shufflePlaylist' : true});
player.setShuffle({'shufflePlaylist' : 1});
player.setShuffle({'shufflePlaylist' : 'true'});
player.setShuffle({'shufflePlaylist' : '1'});
I have also tried copying and example from here....https://developers.google.com/youtube/youtube_player_demo
The Shuffle works here after u load the playlist and click a button.