2012-02-16 74 views
2

我試圖在Vimeo視頻的播放按鈕被點擊後調用一個功能。Vimeo play eventListener在播放按鈕被點擊之前觸發

出於某種原因,在加載iframe時調用該函數,而不是單擊播放時。有人能解釋爲什麼嗎?

這是我的代碼:

// Enable the API on each Vimeo video 
     jQuery('iframe.vimeo').each(function(){ 
      Froogaloop(this).addEvent('ready', ready); 
     }); 

     function ready(playerID){ 
      // Add event listerns 
      // http://vimeo.com/api/docs/player-js#events 
      Froogaloop(playerID).addEvent('play', play(playerID)); 
     } 
     function play(playerID){ 
      alert(playerID + " is playing!!!"); 
     } 

謝謝!

回答

3

Ahhh想通了!

// Enable the API on each Vimeo video 
    jQuery('iframe.vimeo').each(function(){ 
     Froogaloop(this).addEvent('ready', ready); 
    }); 

    function ready(playerID){ 
     // Add event listerns 
     // http://vimeo.com/api/docs/player-js#events 
      Froogaloop(playerID).addEvent('play', function(data) {play(playerID);}); 
    } 
    function play(playerID){ 
     alert(playerID + " is playing!!!"); 
    } 

希望有人會發現有幫助!