为什么onStateChange事件没有被触发?



工作空间:http://jsfiddle.net/WBFa4/51/代码的重要部分是:

swfobject.embedSWF
(
    'http://www.youtube.com/apiplayer?enablejsapi=1&version=3',
    'ytplayer_div1',
'425',
'344',
'8',
null,
null,
{
    allowScriptAccess: 'always',
            allowFullScreen: 'true'
},
{
    id: 'ytplayer_object'
}
);
onYouTubePlayerReady=function() {
    var ytplayer = document.getElementById("ytplayer_object");
    ytplayer.loadVideoById("IMdI_fozMYg");
    ytplayer.addEventListener("onStateChange","Hsc");
}
function Hsc(state) {
  if(state==0) {
     document.getElementById("notif").innerHTML="<p>yeah</p>"; 
     var ytplayer=document.getElementById("ytplayer_object"); 
     ytplayer.loadVideoById("bHQqvYy5KYo");
  }
};

如果有人感兴趣,这里是工作解决方案:http://jsfiddle.net/WBFa4/97/

一段代码:

onytplayerStateChange=function(newState) {
 document.getElementById("notif").innerHTML="<p>yeah</p>";     
 if(newState==0) { // Here I changed state to newStage.
   document.getElementById("notif").innerHTML="<p>yeah</p>"; 
   var ytplayer=document.getElementById("ytplayer_object"); 
   ytplayer.loadVideoById("bHQqvYy5KYo");
 }
}       

Thanks to sunxperous

相关内容

  • 没有找到相关文章