2

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

由于某种原因,该函数在 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!!!");
        }

谢谢!

4

1 回答 1

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

希望有人会觉得这很有帮助!

于 2012-02-16T14:44:11.530 回答