如何在Jwplayer上添加源选择器

问题描述 投票:0回答:1

我有3个M3u8,我想添加到我的jwplayer。在控制栏上,有一个弹出窗口,就像有一个HD按钮或在设置轮中选择HTML。这是我用来执行此操作的代码,但它会加载第一个视频,并且下拉列表中没有按钮可在源之间切换。任何帮助或想法都会很棒!

sources: [{
            file: 'http://playback.akamaized.net/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media/[email protected]?dw=80&ts=1551528000&hdnts=exp=1551700828~acl=/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media*~hmac=e4421dcb61cba40f56b7b2ae210a761b5c0c8a7d815bf90080afacfe0b39a33d',
label: '720P',
},{
            file: 'http://playback.akamaized.net/streams/27460990_8266920_lsikdkamp7ufvbg66kn_1/media/[email protected]?dw=80&ts=1551528000&hdnts=exp=1551700829~acl=/streams/27460990_8266920_lsikdkamp7ufvbg66kn_1/media*~hmac=3964553279fa3788f77d0910bfdbe66791fa93bab43f88b5d54beacb84b2649c',
label: '520P',
},{
            file: 'http://playback.akamaized.net/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media/[email protected]?dw=80&ts=1551528000&hdnts=exp=1551700828~acl=/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media*~hmac=e4421dcb61cba40f56b7b2ae210a761b5c0c8a7d815bf90080afacfe0b39a33d',
label: '480P'


    }],

完整代码

<script src="https://content.jwplatform.com/libraries/Ge4D2jW2.js"></script>
<script>jwplayer.key="sXW0XA1MksiJ6hYVNHKJFCtOB4qTihu2B0xyTyZoMiA="</script>
</head>
<body>
<div id="video"></div><script type='text/javascript'>
jwplayer('video').setup({

       sources: [{
            file: 'http://playback.akamaized.net/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media/[email protected]?dw=80&ts=1551528000&hdnts=exp=1551700828~acl=/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media*~hmac=e4421dcb61cba40f56b7b2ae210a761b5c0c8a7d815bf90080afacfe0b39a33d',
label: 'aaaaa',
},{
            file: 'http://playback.akamaized.net/streams/27460990_8266920_lsikdkamp7ufvbg66kn_1/media/[email protected]?dw=80&ts=1551528000&hdnts=exp=1551700829~acl=/streams/27460990_8266920_lsikdkamp7ufvbg66kn_1/media*~hmac=3964553279fa3788f77d0910bfdbe66791fa93bab43f88b5d54beacb84b2649c',
label: 'aaaa',
},{
            file: 'http://playback.akamaized.net/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media/[email protected]?dw=80&ts=1551528000&hdnts=exp=1551700828~acl=/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media*~hmac=e4421dcb61cba40f56b7b2ae210a761b5c0c8a7d815bf90080afacfe0b39a33d',
label: 'aaa'


    }],
 'height': '390',
 'width': '640',
'autostart': 'true',
 'title': '',

});
</script>
javascript html5 jwplayer
1个回答
0
投票

嗨,最简单的方法是创建一个像这样的m3u8文件。

 #EXTM3U
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1012313,CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=853x480
    https://playback.akamaized.net/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media/[email protected]?dw=80&ts=1551528000&hdnts=exp=1551700828~acl=/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media*~hmac=e4421dcb61cba40f56b7b2ae210a761b5c0c8a7d815bf90080afacfe0b39a33d
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2408695,CODECS="avc1.4d001f,mp4a.40.2",RESOLUTION=924x520
    https://playback.akamaized.net/streams/27460990_8266920_lsikdkamp7ufvbg66kn_1/media/[email protected]?dw=80&ts=1551528000&hdnts=exp=1551700829~acl=/streams/27460990_8266920_lsikdkamp7ufvbg66kn_1/media*~hmac=3964553279fa3788f77d0910bfdbe66791fa93bab43f88b5d54beacb84b2649c
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=3042937,CODECS="avc1.4d001f,mp4a.40.2",RESOLUTION=1280x720
    https://playback.akamaized.net/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media/[email protected]?dw=80&ts=1551528000&hdnts=exp=1551700828~acl=/streams/27460990_8266909_lsiedqtjbbq4ylzyzyc_1/media*~hmac=e4421dcb61cba40f56b7b2ae210a761b5c0c8a7d815bf90080afacfe0b39a33d

    <script src="https://content.jwplatform.com/libraries/Ge4D2jW2.js"></script>
    <script>jwplayer.key="sXW0XA1MksiJ6hYVNHKJFCtOB4qTihu2B0xyTyZoMiA="</script>
    </head>
    <body>
    <div id="video"></div><script type='text/javascript'>
    jwplayer('video').setup({
    "file": "https://s3.us-west-1.wasabisys.com/clear/tst/master.m3u8",
     'height': '390',
     'width': '640',
    'autostart': 'true',
     'title': '',

    });
    </script>
© www.soinside.com 2019 - 2024. All rights reserved.