0

正如您在图像中看到的,在控制台中打印播放器对象时,它会显示所有方法,但是当我单独打印键时,它们无法访问。这是为了表明玩家对象的方法不起作用。我应该怎么办?

var player = {};

function onYouTubeIframeAPIReady1(v) {
   player = new YT.Player('player', {
   height: '390',
   width: '640',
   events: {
      //'onReady': onPlayerReady,
      'onStateChange': onPlayerStateChange
      },
      origin: "http://localhost",
   });
   if (player.D == 'player'){
      makePlaylist(v);      //This is to make sure that the player object has been created.
   }
}


function makePlaylist(videos){
   console.log('makePlaylist', videos, player);
   for (x in player){
      console.log(x);
   }
   player.loadVideoById(videos);
   player.playVideo();
}

4

0 回答 0