Vimeo Froogaloop API无法识别事件 [英] Vimeo Froogaloop API not recognizing an event

查看:554
本文介绍了Vimeo Froogaloop API无法识别事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用froogaloop API识别vimeo的onPlay,onPause和onFinish事件。我尝试过用这个东西想象的一切,但没有运气。

I'm trying to recognize the onPlay, onPause, and onFinish event for vimeo using the froogaloop API. I've tried everything I could imagine with this thing, and no luck.

我在Firefox上遇到这个错误:

I get this error on Firefox:

在Chrome中:

从CDN导入froogaloop:

Importing froogaloop from the CDN:

<script src="http://a.vimeocdn.com/js/froogaloop2.min.js"></script>

我的JS:

$(function(){

    var vimeoPlayer = document.querySelector('iframe');

    $f(vimeoPlayer).addEvent('ready', ready);

    function ready(player_id) {

        froogaloop = $f(player_id);

        function setupEventListeners() {
            function onPlay() {
                froogaloop.addEvent('play',
                function(data) {
                    console.log('play event');
                });
            }

            function onPause() {

                froogaloop.addEvent('pause',
                function(data) {
                    console.log('pause event');
                });
            }

            function onFinish() {
                froogaloop.addEvent('finish',
                function(data) {
                    console.log('finish');
                });
            }
            onPlay();
            onPause();
            onFinish();
        }
        setupEventListeners();
    }

})

我的HTML:

<iframe src="http://player.vimeo.com/video/3718294?api=1" width="623" height="350" frameborder="0" id="iframe-video"></iframe>


推荐答案

经过几个小时的挫折...我有找到了解决方案。

After hours and hours of frustration... I have found the solution.

由于我在iframe上使用了ID ...显然vimeo API会强制您将参数添加到您要提取的URL中(player_id = iframe的ID)。

Since I was using an ID on the iframe... apparently the vimeo API forces you to add the parameter to the URL you are fetching (player_id=iframe-id).

所以iFrame应如下所示:

So the iFrame should look like this:

<iframe src="//player.vimeo.com/video/3718294?api=1&player_id=promo-vid" 
        width="623" height="350" frameborder="0"
        id="promo-vid">
</iframe>

特别感谢Drew Baker指出这一点: http://vimeo.com/forums/topic:38114#comment_5043696

Special thanks to Drew Baker for pointing this out: http://vimeo.com/forums/topic:38114#comment_5043696

这篇关于Vimeo Froogaloop API无法识别事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆