youtube API 无法正常播放

youtube API does not play normally

我想这个播放列表的音乐没有在播放中。但 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)

Press Pause button and control play bar.->Can play music. But now music pause state, play button is not activate. Always Pause button on activate. But play/pause function is work.

尝试

 function onPlayerReady(event) {
        player.loadPlaylist({'listType' : 'playlist', 'list':'myplaylist','index' : '0','startSeconds':'0','suggestedQuality':'default' });
        setTimeout(setShuffleFunction, 1000);

        player.play(); 
      }