Youtube iFrame'播放器'对象的方法无法访问,可能是什么原因?

时间:2014-08-03 06:12:11

标签: youtube youtube-api youtube-iframe-api

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

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();
}

0 个答案:

没有答案