JW Player 6:向播放列表添加多个源

时间:2015-06-02 07:50:43

标签: javascript jwplayer

所以我看到了如何从链接加载播放列表的original example。我知道有一个API method playlist[].sources[].file来添加来源。我把它放在一起很困难。我只是加载了文件名来试图变得棘手,但是这会导致播放列表错误。

<div>Watch the quick tutorial on <a href="javascript:loadVideo('basics','_images/title2.png')">the basics</a> or <a href="javascript:loadVideo('destruction','_images/title2.png')">destruction</a>.</div>
<div id="tutorial">Loading the player...</div>
<script type="text/javascript">

    var myFile = 'basics';
    var myImage = '_images/title2.png';

    jwplayer("tutorial").setup({
        width: 512,
        height: 320,
        playlist: [{
            image: "_images/title2.png",
            sources: [
                {file: "_media/"+myFile+".webm"},
                {file: "_media/"+myFile+".mp4"}
            ]
        }]
    });

    function loadVideo(myFile,myImage) {
        jwplayer().load([{
            file: myFile,
            image: myImage
        }]);
        jwplayer().play();
    };
</script>

如何将playlist[].sources[].fileload(playlist)方法一起使用?

1 个答案:

答案 0 :(得分:0)

这个怎么样?

function loadVideo(myFile,myImage,myFile2) {
        jwplayer().load([{
            image: myImage,
            sources: [
                {file: myFile},
                {file: myFile2}
            ]
        }]);
    jwplayer().play();
};