我正在使用多个HTMLLoader
将 youtube 视频嵌入 Air 应用程序(每个加载程序一个),当我添加两个以上时,它会导致 API 中的所有玩家超过第二个错误。播放器似乎工作正常,但从未调用事件,并且 player.pauseVideo 未定义。
TypeError: Result of expression 'b' [undefined] is not an object.
at http://s.ytimg.com/yts/jsbin/www-embed-player-vflJ4hakx.js : 206
at http://s.ytimg.com/yts/jsbin/www-embed-player-vflJ4hakx.js : 205
at http://s.ytimg.com/yts/jsbin/www-embed-player-vflJ4hakx.js : 204
at http://s.ytimg.com/yts/jsbin/www-embed-player-vflJ4hakx.js : 199
我的嵌入代码:
function SetupYoutubePlayer(divName, videoID) {
_videoID = videoID;
_divName = divName;
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 _videoID;
var _divName;
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player(_divName, {
height: '100%',
width: '100%',
wmode: 'opaque',
autohide: '1',
modestbranding: '1',
frameborder: "0",
showinfo: '0',
videoId: _videoID,
playerVars: {
'wmode': 'opaque',
'rel': 0,
'autohide': 1,
'modestbranding': 1,
'frameborder': 0,
'showinfo': 0,
},
events: {
'onStateChange': onPlayerStateChange
}
});
}