0

这是工作空间: 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");
  }
};
4

1 回答 1

0

如果有人感兴趣,这里的工作解决方案: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");
 }
}       

感谢sunxperous

于 2013-06-21T07:27:52.413 回答