jQuery and Vimeo Froogaloop API

后端 未结 2 1004
青春惊慌失措
青春惊慌失措 2021-02-04 19:32

I\'m building a plugin to WordPress and so far so good with the PHP library. But I am having some issues with the JavaScript API.

I\'m trying to use it with jQuery, and

相关标签:
2条回答
  • 2021-02-04 19:56

    One issue is that addEvent is both a function that you've defined and also a method of the $f(player) object. It appears that you're confusing the two. The addEvent method of the $f(player) object only takes two arguments, the name of the player event and the function to be called. It should be used as $f(your-iframe).addEvent('vimeo event', your_function);

    Your addEvent function will unify events between IE and W3C methods. It's not needed because you're using jQuery. jQuery(whatever).click() does the same thing. I don't see any part of your snippet where you need it but if you do, I'd just use the jQuery method.

    Also, the video player object should be $f(player) instead of $f(player).vimeoPlayer

    Try this

    jQuery('iframe.vimeo-player').each(function(){
        $f(this).addEvent('ready', ready);
    });
    

    Another thing to note is that any additional player events need to be added from your ready callback function. For example:

    function ready(player_id){
        $f(player_id).addEvent('play', play);
        $f(player_id).api('play');
        alert("Ready!!!");
    }
    function play(){
        alert("Playing!!!");
    }
    

    I've had a hard time finding the info I want on Vimeo's Froogaloop api but after scouring Vimeo Froogaloop API Playground about a dozen times I'm starting to get the idea of how it works.

    Good luck!

    0 讨论(0)
  • 2021-02-04 19:59

    Instead of $f(player).vimeoPlayer.addEvent try $(this).addEvent.

    0 讨论(0)
提交回复
热议问题