如何自动启动Popcorn jPlayer插件?

时间:2014-02-06 19:05:08

标签: javascript html5 jplayer popcornjs

我使用jPlayer和Popcorn jPlayer插件创建了一个播放器。设置如下:

 var $player = Popcorn
                   .jplayer('#jquery_jplayer_1', {
                        media: {
                            m4v: Content.videoURL,
                            poster:  Content.posterURL
                        },
                        options: {
                            swfPath: "swf",
                            supplied: "m4v",
                            size: {
                                width: "640px",
                                height: "360px",
                                cssClass: "jp-video-360p"
                            },
                            smoothPlayBar: true,
                            keyEnabled: true
                        }
                    });

媒体准备好后,如何自动启动播放器?我可以使用$ player参考吗?

1 个答案:

答案 0 :(得分:0)

想出来。将ready函数属性添加到选项:

var $player = Popcorn
               .jplayer('#jquery_jplayer_1', {
                    media: {
                        m4v: Content.videoURL,
                        poster:  Content.posterURL
                    },
                    options: {
                        ready: function() {
                            $player.play();
                        },
                        swfPath: "swf",
                        supplied: "m4v",
                        size: {
                            width: "640px",
                            height: "360px",
                            cssClass: "jp-video-360p"
                        },
                        smoothPlayBar: true,
                        keyEnabled: true
                    }
                });