Vimeo播放事件侦听器在单击“播放”按钮之前启动

Vimeo play eventListener fires before Play button is clicked

本文关键字:播放 按钮 启动 单击 事件 侦听器 Vimeo      更新时间:2023-09-26

我正试图在点击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!!!");
        }

谢谢!

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

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