JW Player/ColorBox 回调未触发

发布于 2025-01-03 19:01:46 字数 1754 浏览 4 评论 0原文

将 JW Player 与 ColorBox 和 jQuery 一起使用,回调似乎没有正确触发。下面是一个片段:

    $(".thumbnail").live('click', function(event) {

        event.preventDefault();

        var videoFile = $(this).attr('id');

        jwplayer('viewPort').setup({
                    'flashplayer': '../jwplayer/player.swf',
                           'file': 'data/' + videoFile,
                             'id': 'playerID',
                          'width': '100%',
                         'height': '100%',
                     'controlbar':'bottom',
            'controlbar.idlehide':'false',
                           'skin':'../jwplayer/skins/big.zip',
                        'plugins': {
                                    'gapro-2': { },
                                   },
                     'onComplete': function () {
                                      $("#colorBox").colorbox.close();
                                   }
        });

        $("#colorBox").colorbox({
               'width':"80%",
              'height':"80%",
          'transition':"fade",
           'scrolling':false,
              'inline':true,
                'href':"#viewPort",
                'open':true,
          'onComplete': function () {
                            jwplayer('viewPort').play();
                        },
            'onClosed': function () {
                            jwplayer('viewPort').remove();
                        }
        });

    });

未触发的是 jwplayercolorboxonComplete

我可以在控制台 (Firebug) 中执行命令 $("#colorBox").colorbox.close(); 并且它确实关闭。与 jwplayer('viewPort').play(); 相同。

这可能是方法名称之间的冲突吗?因为 onClosed 触发得很好。

Using JW Player with ColorBox and jQuery and it does not appear that the callbacks are firing correctly. Here's a snippet:

    $(".thumbnail").live('click', function(event) {

        event.preventDefault();

        var videoFile = $(this).attr('id');

        jwplayer('viewPort').setup({
                    'flashplayer': '../jwplayer/player.swf',
                           'file': 'data/' + videoFile,
                             'id': 'playerID',
                          'width': '100%',
                         'height': '100%',
                     'controlbar':'bottom',
            'controlbar.idlehide':'false',
                           'skin':'../jwplayer/skins/big.zip',
                        'plugins': {
                                    'gapro-2': { },
                                   },
                     'onComplete': function () {
                                      $("#colorBox").colorbox.close();
                                   }
        });

        $("#colorBox").colorbox({
               'width':"80%",
              'height':"80%",
          'transition':"fade",
           'scrolling':false,
              'inline':true,
                'href':"#viewPort",
                'open':true,
          'onComplete': function () {
                            jwplayer('viewPort').play();
                        },
            'onClosed': function () {
                            jwplayer('viewPort').remove();
                        }
        });

    });

The ones not firing are the onComplete for jwplayer and colorbox.

I can execute the command $("#colorBox").colorbox.close(); in the console (Firebug) and it does close. Same for jwplayer('viewPort').play();

Could it be a collision between the method names? Because onClosed fires just fine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一萌ing 2025-01-10 19:01:46

对于 JWPlayer,您应该将事件处理程序放在选项对象的 events 属性内:

jwplayer(...).setup({
    ...
    events : {
        onComplete : function () {
            console.log('Chicken\'s Done!');
        }
    }
});

以下是文档中描述如何注册事件处理程序部分的链接:http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12540/javascript-api-reference#Events

我也不是熟悉 Colorbox,所以我不确定如何初始化它的回调,但文档指出您可以绑定到全局 onComplete 事件,如下所示:

$(document).bind('cbox_complete', function(){
    setTimeout($.colorbox.next, 1500);
});

来源:http://jacklmoore.com/colorbox/(靠近底部的是“事件挂钩”)

For JWPlayer you are supposed to put the event handlers inside the events property of the options object:

jwplayer(...).setup({
    ...
    events : {
        onComplete : function () {
            console.log('Chicken\'s Done!');
        }
    }
});

Here's a link to the section in the documentation that describes how to register event handlers: http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12540/javascript-api-reference#Events

I'm not too familiar with Colorbox so I'm not sure how you initialize a callback for it but the documentation states that you can bind to a global onComplete event like this:

$(document).bind('cbox_complete', function(){
    setTimeout($.colorbox.next, 1500);
});

Source: http://jacklmoore.com/colorbox/ (near the bottom are "Event Hooks")

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文