我似乎无法让我的 youtube javascript 给我正确的视频错误。例如,下面的代码应该给我错误代码 150,但它给了我 0。
在 HTML 上嵌入代码
<object width='710' height='400' style='z-index: 1;'>
<param name='movie' value='https://www.youtube.com/v/Ze8bj80qL_I?version=3&enablejsapi=1&autoplay=1&rel=0&wmode=transparent'></param>
<param name='allowFullScreen' value='true'></param>
<param name='allowScriptAccess' value='always'></param>
<param name='wmode' value='transparent'></param>
<embed src='https://www.youtube.com/v/Ze8bj80qL_I?version=3&enablejsapi=1&autoplay=1&rel=0&wmode=transparent' type='application/x-shockwave-flash' allowfullscreen='true' allowScriptAccess='always' width='710' height='400' id='myytplayer' wmode='transparent'></embed>
</object>
Javascript:
function onPlayerError(event) {
alert(event);
}
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("myytplayer");
ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
ytplayer.addEventListener("onError", "onPlayerError");
$(ytplayer).attr({
"src" : url.replace('?rel=0', '')+"?wmode=transparent",
"wmode" : "Opaque"
});
}