2011-12-21 41 views
0

我正在使用jQuery Youtube插件來嵌入YouTube視頻並在視頻中使用一些API方法。jquery youtube插件 - 調用方法

我有以下代碼:

<div id="player"></div> 
<script type="text/javascript"> 
    jQuery("#player").tubeplayer({ 
     width: 600, // the width of the player 
     height: 450, // the height of the player 
     allowFullScreen: "true", // true by default, allow user to go full screen 
     initialVideo: "VIDEO_ID", // the video that is loaded into the player 
     preferredQuality: "default",// preferred quality: default, small, medium, large, hd720 
     onPlay: function(id){}, // after the play method is called 
     autoPlay: true, 
     onPause: function(){}, // after the pause method is called 
     onStop: function(){}, // after the player is stopped 
     onSeek: function(time){}, // after the video has been seeked to a defined point 
     onMute: function(){}, // after the player is muted 
     onUnMute: function(){}, // after the player is unmuted 
     onPlayerEnded: function(){alert('ENDED')}, 
    }); 
</script> 

此播放視頻很好,但是當影片結束,我期望的onPlayerEnded()功能來踢,給我一個alert('Ended'),這沒有關係」噸。

有沒有人在任何方向指出我使用過這個插件,爲什麼這是這種情況?

非常感謝

+2

是它確定你把最後一個逗號在onPlayerEnded? – bondythegreat 2011-12-21 11:55:59

+0

只有IE可能與最後一個逗號有問題 – 2011-12-21 11:57:33

+0

IE 7,8和9都不顯示視頻。即使添加了SWFObject配置 – terrid25 2011-12-22 11:28:23

回答

0

它工作正常,可能是你的瀏覽器有問題,嘗試改爲使用的console.log警報,並檢查你安慰。

我把你的代碼中的jsfiddle和它的作品 http://jsfiddle.net/sabri/wHpmM/

+1

使用Chrome,似乎解決了這個問題,我現在看到了警報 – terrid25 2011-12-21 12:16:23

+1

這看起來像是Ubuntu 11.10上的FireFox 8/9中的一個錯誤。它在Mac OS X 10.7以及Chrome和IE上運行FF,而在Ubuntu中不是FF,這很奇怪。 – terrid25 2011-12-21 15:43:58