是否可以添加一个标题轨道到jwplayer实例后设置



我有一个html模板,当发布时,列出了该故事的变量,其中一个是一个封闭的标题文件,如果已经为该故事制作了标题:

var file_cc = "../xml/cc/example.vtt";

在外部js文件我设置我的播放器(其他变量来自故事页):

jwplayer("vplayer").setup({
    icons: false,
    sources: [
       {file: origurl},
       {file: origurlsd}
    ],
    image: origimg,
    width: "70%",
    aspectratio: "16:9",
    abouttext: "...",
    aboutlink: "...",
    skin: "/res/libraries/jwplayer/skins/target-v6-11/glow.xml"
});

在外部js中,我然后使用.get()

检测file_cc变量是否存在
$.get(file_cc, function() {
    console.log("found file")
})

但是现在,在。get()函数的。done()和fail()部分中,我想用tracks:数组更新jwplayer("vplayer)

我该怎么做?

我不知道您正在使用的完整代码,所以我将采取有根据的猜测:

var jw = jwplayer("vplayer");
jw.setup({
    icons: false,
    sources: [
       {file: origurl},
       {file: origurlsd}
    ],
    tracks: [{
        file: "cc_file",
        kind: "captions",
        'default': true,
        label: 'English'
    }],
    image: origimg,
    width: "70%",
    aspectratio: "16:9",
    abouttext: "...",
    aboutlink: "...",
    skin: "/res/libraries/jwplayer/skins/target-v6-11/glow.xml"
});
$.get(file_cc, function() {
    console.log("found file");
    var ccList = jw.getCaptionsList();
    var ccList[1] = file_cc;    
    ccList.setCurrentCaptions(1);
    jw.on('complete', done);
    jw.on('error', fail);
    function done() {...}
    function fail() {...}
});

要更清楚地理解这种混乱,请参阅:http://support.jwplayer.com/customer/en/portal/articles/1413089-javascript-api-reference#captions

由于标题列表完全依赖于JW Player的单个设置(如Ethan所述),也许您可以通过JW Player的事件调用$.get()。

var jw = jwplayer("vplayer");
jw.setup({
    icons: false,
    sources: [
       {file: origurl},
       {file: origurlsd}
    ],
    tracks: [{
        file: "cc_file",
        kind: "captions",
        'default': true,
        label: 'English'
    }],
    image: origimg,
    width: "70%",
    aspectratio: "16:9",
    abouttext: "...",
    aboutlink: "...",
    skin: "/res/libraries/jwplayer/skins/target-v6-11/glow.xml"
});
jw.on('captionsList', function(event){
    $.get('cc_file', function() {...}
});
jw.on('captionsChanged', function(event){...});

相关内容

  • 没有找到相关文章

最新更新