在jQuery中的Flowplayer上将autoPlay设置为false [英] set autoPlay false on Flowplayer in jQuery

查看:161
本文介绍了在jQuery中的Flowplayer上将autoPlay设置为false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery和Flowplayer将FLV文件的链接转换为嵌入式视频,如下所示:

I'm using jQuery and Flowplayer to turn links to FLV files into embedded videos like this:

$(document).ready(function() {
    if($('a[type^="video"]').length > 0) {
        $('a[type^="video"]').each(function() {
            var video_path = $(this).attr('href');
            var video_box  = $(this).parent();
            video_box.html('');
            video_box.css('width', '680px');
            video_box.css('height', '460px');
            video_box.flowplayer('/sites/default/files/flowplayer-3.2.7.swf', video_path);
        });
    }
});

除了所有视频均同时开始播放之外,此方法工作正常.我尝试了几种不同的方式添加autoPlay: false,但是到目前为止没有一种有效.从文档看来,我应该可以这样做:

This is working fine except that all the videos start playing simultaneously. I've tried adding autoPlay: false several different ways, but so far none have worked. From the documentation it seems like I should be able to do it this way:

video_box.flowplayer('/sites/default/files/flowplayer-3.2.7.swf', video_path, {clip: {autoPlay: false}});

但这不起作用.

推荐答案

我让它像这样工作:

$(document).ready(function() {
    $('a[type^="video"]').each(function(index) {
        var video_path = $(this).attr('href');
        var video_box  = $(this).parent();
        video_box.html('');
        video_box.css('width', '680px');
        video_box.css('height', '460px');
        video_box.attr('id', 'player-' + index);
        $f(video_box.attr('id'), '/sites/default/files/flowplayer-3.2.7.swf', {
            clip: {
                autoPlay: false,
                url: video_path
            }
        });
    });
});

使$f()函数正常工作的关键是为其赋予ID.我正在使用的div没有ID,因此我在行video_box.attr('id', 'player-' + index);中给了他们一个.

The key to getting the $f() function to work was to give it an id. The divs I was using didn't have ids so I gave them one with the line video_box.attr('id', 'player-' + index);.

我仍然不知道为什么我不能让jQuery object.flowplayer()方法接受autoPlay: false属性.但是我想使用$f()函数也是一样.感谢您的帮助.

I still don't know why I couldn't get the jQuery object.flowplayer() method to accept the autoPlay: false property. But I suppose using the $f() function is just as good. Thanks for the help.

这篇关于在jQuery中的Flowplayer上将autoPlay设置为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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