Vimeo play eventListener在单击“播放”按钮之前触发

时间:2012-02-16 04:51:22

标签: javascript html vimeo froogaloop

点击Vimeo视频上的播放按钮后,我正试图调用一个函数。

出于某种原因,在iframe加载时调用该函数,而不是在单击play时调用。有人可以解释一下原因吗?

这是我的代码:

    // 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!!!");
        }

谢谢!

1 个答案:

答案 0 :(得分:3)

啊,他想出来了!

// 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!!!");
    }

希望有人会觉得有帮助!