Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ebbcd18

Browse files
committed
[feta]支持HLS创建多个实例
1 parent 1d90b8f commit ebbcd18

File tree

3 files changed

+77
-9
lines changed

3 files changed

+77
-9
lines changed

demos/base-demo/ezuikit.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,15 @@ var HLS = /*#__PURE__*/function () {
319319

320320
_classCallCheck$1(this, HLS);
321321

322-
addJs("https://open.ys7.com/sdk/js/2.0/js/hls.min.js", function () {
322+
addJs("https://open.ys7.com/assets/ezuikit_v3.4/js/hls.js", function () {
323323
console.log("加载hls.min.js成功", window.Hls);
324324
console.log("isSupportHls", window.Hls.isSupported());
325325

326326
if (window.Hls.isSupported()) {
327327
_this.initHLS(videoId, url);
328328
}
329+
}, function () {
330+
return !!window.Hls;
329331
});
330332
}
331333

@@ -31912,9 +31914,40 @@ var matchTemplate = function matchTemplate(templateName, params) {
3191231914
};
3191331915

3191431916
var isVersion2Available = function isVersion2Available() {
31917+
var ua = window.navigator.userAgent.toLowerCase(); //获取用户端信息
31918+
31919+
var info = {
31920+
sa: /version.*safari/.test(ua),
31921+
//匹配Safari浏览器
31922+
ch: /chrome/.test(ua),
31923+
//匹配Chrome浏览器
31924+
ff: /gecko/.test(ua) && !/webkit/.test(ua) //匹配Firefox浏览器
31925+
31926+
};
3191531927
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
31916-
var isSharedArrayBuffer = window.SharedArrayBuffer;
31917-
return isSharedArrayBuffer && !isMobile;
31928+
31929+
if (isMobile) {
31930+
return false;
31931+
} else if (info.ch) {
31932+
var getChromeVersion = function getChromeVersion() {
31933+
var arr = window.navigator.userAgent.split(' ');
31934+
var chromeVersion = '';
31935+
31936+
for (var i = 0; i < arr.length; i++) {
31937+
if (/chrome/i.test(arr[i])) chromeVersion = arr[i];
31938+
}
31939+
31940+
if (chromeVersion) {
31941+
return Number(chromeVersion.split('/')[1].split('.')[0]);
31942+
} else {
31943+
return false;
31944+
}
31945+
};
31946+
31947+
return getChromeVersion() > 91 && !!window.SharedArrayBuffer;
31948+
}
31949+
31950+
return false;
3191831951
};
3191931952

3192031953
var EZUIKitPlayer = /*#__PURE__*/function () {

demos/base-demo/hls.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
<body>
1212
<div className="demo">
1313
<h2>视频模式使用示例:</h2>
14-
<video id="hlsId" autoplay controls src="https://open.ys7.com/v3/openlive/C78957921_1_2.m3u8?expire=1680953107&id=434433876120637440&t=007a292c63640f6de88c92e43b5d72233f6b1ed5d69560122ba2ac294d01237e&ev=100"></video>
15-
<p style="font-style: italic;">播放多个视频,可初始化多个实例,参考:/demos/base-demo/multi-demo</p>
14+
<video id="hlsId" autoplay controls style="width: 600px;height:400px"></video>
15+
<video id="hlsId2" autoplay controls style="width: 600px;height:400px"></video>
1616
</div>
1717
<script>
18-
var hlsDemo = new EZUIKit.HLS("hlsId","https://hls01open.ys7.com/openlive/6e0b2be040a943489ef0b9bb344b96b8.m3u8");
18+
var hlsDemo = new EZUIKit.HLS("hlsId","https://open.ys7.com/v3/openlive/C78957921_1_2.m3u8?expire=1687488306&id=461844489422516224&t=96ea4ce49d2ea4f2f65d045edbe8fa1a51ef9fac6f38e150052bc64a91c27db7&ev=100");
19+
20+
var hlsDemo2 = new EZUIKit.HLS("hlsId2","https://open.ys7.com/v3/openlive/G39444019_1_2.m3u8?expire=1687487466&id=461840962679742464&t=c076d5a5ad56090e919a6a2500b96169c20a77874cce866a87a7d65e493e6f2f&ev=100");
1921
</script>
2022
</body>
2123

ezuikit.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,15 @@ var HLS = /*#__PURE__*/function () {
319319

320320
_classCallCheck$1(this, HLS);
321321

322-
addJs("https://open.ys7.com/sdk/js/2.0/js/hls.min.js", function () {
322+
addJs("https://open.ys7.com/assets/ezuikit_v3.4/js/hls.js", function () {
323323
console.log("加载hls.min.js成功", window.Hls);
324324
console.log("isSupportHls", window.Hls.isSupported());
325325

326326
if (window.Hls.isSupported()) {
327327
_this.initHLS(videoId, url);
328328
}
329+
}, function () {
330+
return !!window.Hls;
329331
});
330332
}
331333

@@ -31912,9 +31914,40 @@ var matchTemplate = function matchTemplate(templateName, params) {
3191231914
};
3191331915

3191431916
var isVersion2Available = function isVersion2Available() {
31917+
var ua = window.navigator.userAgent.toLowerCase(); //获取用户端信息
31918+
31919+
var info = {
31920+
sa: /version.*safari/.test(ua),
31921+
//匹配Safari浏览器
31922+
ch: /chrome/.test(ua),
31923+
//匹配Chrome浏览器
31924+
ff: /gecko/.test(ua) && !/webkit/.test(ua) //匹配Firefox浏览器
31925+
31926+
};
3191531927
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
31916-
var isSharedArrayBuffer = window.SharedArrayBuffer;
31917-
return isSharedArrayBuffer && !isMobile;
31928+
31929+
if (isMobile) {
31930+
return false;
31931+
} else if (info.ch) {
31932+
var getChromeVersion = function getChromeVersion() {
31933+
var arr = window.navigator.userAgent.split(' ');
31934+
var chromeVersion = '';
31935+
31936+
for (var i = 0; i < arr.length; i++) {
31937+
if (/chrome/i.test(arr[i])) chromeVersion = arr[i];
31938+
}
31939+
31940+
if (chromeVersion) {
31941+
return Number(chromeVersion.split('/')[1].split('.')[0]);
31942+
} else {
31943+
return false;
31944+
}
31945+
};
31946+
31947+
return getChromeVersion() > 91 && !!window.SharedArrayBuffer;
31948+
}
31949+
31950+
return false;
3191831951
};
3191931952

3192031953
var EZUIKitPlayer = /*#__PURE__*/function () {

0 commit comments

Comments
 (0)