Flowplayer自动播放播放列表,视频之间有延迟

时间:2011-08-23 19:38:41

标签: javascript flowplayer

有没有人知道如何在每个播放列表剪辑的末尾添加延迟。 我正在尝试这样的事情:

flowplayer("a.flowplayer", {src: "/flowplayer2/dist/swf/flowplayer-3.2.7.swf",wmode: 'transparent'}, {
    clip: {
        onFinish: function(clip) {
           this.pause();
           var obj = this;
           setTimeout(function(){
              obj.play()
           },5*1000);

        },
    },
    plugins: {
        controls: {
            autoHide: "always"
        },
        ova: {
            url: '/flowplayer2/dist/swf/d/ova.swf',
            "autoPlay" : true,
            "autoBuffering": true,
            "shows": {
                "streams": [
                    { "file":"one.flv"},
                    { "file":"two.flv"},
                    { "file":"three.flv"}
                ]
            },
            "ads": {
                "pauseOnClickThrough": true,
                "displayCompanions": true,
                "restoreCompanions": false,
                "companions": [{
                    "id":"lcBannerDiv",
                    "width":"300",
                    "height":"250",
                    "resourceType": "iframe"
                }],
                "notice": { show: false },
                "schedule": [{
                    "position": "pre-roll",
                    "server": {
                        "type": "direct",
                        "tag": VAST_URL
                    }
                }]
            }
        }
    }
});

但它不起作用,它只是在播放第一个视频后停止。

谢谢你, 梅德

1 个答案:

答案 0 :(得分:2)

我从未在Flowplayer上使用过OVA插件,但从技术上讲,你的onFinish功能只是暂停播放器,之后再次播放。然后它会到达剪辑的末尾并停止,我想。

如果您的播放器从OVA插件获得播放列表(您可以通过调用$f().getPlaylist()在JavaScript控制台上进行检查,它会返回一系列剪辑),然后考虑更改您的onFinish函数:

flowplayer("a.flowplayer", {src: "/flowplayer2/dist/swf/flowplayer-3.2.7.swf",wmode: 'transparent'}, {
    clip: {
        onFinish: function(clip) {
            // First check where you are in your playlist
            var currentClipIndex = this.getClip().index;
            // Get length of playlist
            var playlistLength = this.getPlaylist().length;
            // save handle to player instance
            var fp = this;
            // check if there is a clip after the current (last clip has index "playlistLength -1")
            if (currentClipIndex < playlistLength -1) {
                setTimeout(function() {
                    // tell fp to play clip with next index
                    fp.play(currentClipIndex + 1);
                // in five seconds
                }, 5*1000)
            }
        },
    },
    {...}
});