【问题标题】:Vimeo jQuery Event Call BackVimeo jQuery 事件回调
【发布时间】:2013-01-06 02:03:56
【问题描述】:

我正在尝试让我的 Vimeo Embedded 播放器在视频播放完毕后调用一个函数。我无法让回调函数调用....

$.getJSON('http://www.vimeo.com/api/oembed.json?url=' + encodeURIComponent('http://vimeo.com/7100569') + '&width=513&height=287&callback=?', function(data) {
    $('#mediaplayerHolder').html(data.html);
    $('iframe').each(function() {
        $f(this).addEvent('ready', function(player_id) {
            $f(player_id).addEvent('finish', function() {
                alert("finish");    
            });
        });
    });
});

【问题讨论】:

    标签: jquery callback vimeo


    【解决方案1】:

    我想通了......对于其他有同样问题的人来说,这是因为几件事。

    1) 我没有

    api=1
    

    在 JSON 字符串中。

    2) 我需要 JSON 字符串和 iframe 中的 ID。

    我把它全部放在一个调用视频的函数中:

    function playVideo(ID,autoPlay,playNext) {
        $('#mediaplayerHolder').find("iframe").remove();
    
        $.getJSON('http://www.vimeo.com/api/oembed.json?url=' + encodeURIComponent('http://vimeo.com/' + ID) + '&title=0&byline=0&portrait=0&autoplay=' + autoPlay + '&width=513&height=287&api=1&player_id=mediaplayer&callback=?', function(data) {
            $(data.html).attr("ID","mediaplayer").appendTo('#mediaplayerHolder');
    
            var iframe = $("iframe")[0],
                player = $f(iframe);
    
            player.addEvent("ready", function() {
                player.addEvent("finish",function() {
                    if (playNext) {
                        $(".occupied:not(#" + ID + "):first").find(".playBtn").click();
                        $("#" + ID).find(".removeBtn").click(); 
                    }
                });
            });
        }); 
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-05
      • 1970-01-01
      • 2015-09-08
      • 2015-08-14
      • 2012-01-12
      • 2023-03-15
      • 1970-01-01
      相关资源
      最近更新 更多