ezuikit-js 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demos/base-demo/ezuikit.js +497 -177
- package/ezuikit.js +711 -85
- package/package.json +1 -1
|
@@ -201,7 +201,7 @@ const request = (url, method, params, header, success, error) => {
|
|
|
201
201
|
|
|
202
202
|
class HLS {
|
|
203
203
|
constructor(videoId, url) {
|
|
204
|
-
addJs("https://
|
|
204
|
+
addJs("https://open.ys7.com/sdk/js/2.0/js/hls.min.js", () => {
|
|
205
205
|
console.log("加载hls.min.js成功", window.Hls);
|
|
206
206
|
console.log("isSupportHls", window.Hls.isSupported());
|
|
207
207
|
if (window.Hls.isSupported()) {
|
|
@@ -317,8 +317,9 @@ class FLV {
|
|
|
317
317
|
function insertAfter(newElement, targetElement) { var parent = targetElement.parentNode; if (parent.lastChild == targetElement) { parent.appendChild(newElement); } else { parent.insertBefore(newElement, targetElement.nextSibling); } }
|
|
318
318
|
|
|
319
319
|
class Status {
|
|
320
|
-
constructor(id) {
|
|
320
|
+
constructor(jSPlugin,id) {
|
|
321
321
|
this.id = id;
|
|
322
|
+
this.jSPlugin = jSPlugin;
|
|
322
323
|
}
|
|
323
324
|
toString() {
|
|
324
325
|
return `${this.coreX}-${this.coreY}`;
|
|
@@ -340,6 +341,10 @@ class Status {
|
|
|
340
341
|
var loadingContainerDOM = document.createElement('div');
|
|
341
342
|
loadingContainerDOM.setAttribute('id', `${id}-loading-id-0`);
|
|
342
343
|
var style = 'position:absolute;outline:none;pointer-events:none;';
|
|
344
|
+
console.log("this.jSPlugin",this.jSPlugin);
|
|
345
|
+
if(typeof this.jSPlugin.poster === 'string') {
|
|
346
|
+
style += `background: url(${this.jSPlugin.poster}) no-repeat;background-size: cover;`;
|
|
347
|
+
}
|
|
343
348
|
style += 'width: 100%;';
|
|
344
349
|
style += 'height: 100%;';
|
|
345
350
|
style += 'top:' + offsetTop + ';';
|
|
@@ -400,6 +405,14 @@ class Status {
|
|
|
400
405
|
for (var i = elements.length - 1; i >= 0; i--) {
|
|
401
406
|
elements[i].parentNode.removeChild(elements[i]);
|
|
402
407
|
}
|
|
408
|
+
if(document.getElementById(`${this.id}-loading-id-0`)) {
|
|
409
|
+
document.getElementById(`${this.id}-loading-id-0`).style.background = 'none';
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
setPoster(pic) {
|
|
413
|
+
if(document.getElementById(`${this.id}-loading-id-0`)) {
|
|
414
|
+
document.getElementById(`${this.id}-loading-id-0`).style.backgroundImage = `url(${pic})`;
|
|
415
|
+
}
|
|
403
416
|
}
|
|
404
417
|
loadingEnd() {
|
|
405
418
|
var loadingItemContainerDOM = document.getElementById(`${this.id}-loading-item-0`);
|
|
@@ -410,6 +423,7 @@ class Status {
|
|
|
410
423
|
loadingContainerDOM.parentNode.removeChild(loadingContainerDOM);
|
|
411
424
|
}
|
|
412
425
|
}
|
|
426
|
+
document.getElementById(`${this.id}-loading-item-0`).style.background = 'none';
|
|
413
427
|
}
|
|
414
428
|
}
|
|
415
429
|
|
|
@@ -23789,6 +23803,9 @@ var TimeLine$1 = function (jsPlugin) {
|
|
|
23789
23803
|
class Rec {
|
|
23790
23804
|
constructor(jSPlugin) {
|
|
23791
23805
|
this.jSPlugin = jSPlugin;
|
|
23806
|
+
if(!document.getElementById(`${this.jSPlugin.id}-audioControls`)) {
|
|
23807
|
+
return false;
|
|
23808
|
+
}
|
|
23792
23809
|
this.currentTimeWidth = 1; //回放时间轴尺度 1~4
|
|
23793
23810
|
this.timer = null;
|
|
23794
23811
|
this.date = new Date();
|
|
@@ -23909,10 +23926,10 @@ C11.4,16.3,11,16.6,10.6,16.6z" />
|
|
|
23909
23926
|
});
|
|
23910
23927
|
this.syncTimeLine();
|
|
23911
23928
|
// 加载日期选择器
|
|
23912
|
-
addCss(
|
|
23913
|
-
addJs(
|
|
23914
|
-
addJs(
|
|
23915
|
-
addJs(
|
|
23929
|
+
addCss(`${this.jSPlugin.staticPath}/rec/datepicker.min.css`);
|
|
23930
|
+
addJs(`${this.jSPlugin.staticPath}/rec/jquery.min.js`, () => {
|
|
23931
|
+
addJs(`${this.jSPlugin.staticPath}/rec/datepicker.js`, () => {
|
|
23932
|
+
addJs(`${this.jSPlugin.staticPath}/rec/datepicker.zh-CN.js`, () => {
|
|
23916
23933
|
// 日期选择:
|
|
23917
23934
|
$(`#${this.jSPlugin.id}-datepicker`).datepicker({
|
|
23918
23935
|
autoShow: false,
|
|
@@ -24050,7 +24067,8 @@ C11.4,16.3,11,16.6,10.6,16.6z" />
|
|
|
24050
24067
|
}
|
|
24051
24068
|
this.timer = setInterval(() => {
|
|
24052
24069
|
var getOSDTimePromise = this.jSPlugin.getOSDTime();
|
|
24053
|
-
getOSDTimePromise.then((
|
|
24070
|
+
getOSDTimePromise.then((data) => {
|
|
24071
|
+
var v = data.data;
|
|
24054
24072
|
if (v === -1) {
|
|
24055
24073
|
console.log("获取播放时间错误");
|
|
24056
24074
|
} else {
|
|
@@ -25216,9 +25234,9 @@ class Talk {
|
|
|
25216
25234
|
audioRightDOM.setAttribute("controls", true);
|
|
25217
25235
|
audioRight.appendChild(audioRightDOM);
|
|
25218
25236
|
|
|
25219
|
-
addJs(
|
|
25220
|
-
addJs(
|
|
25221
|
-
addJs(
|
|
25237
|
+
addJs(`${this.jSPlugin.staticPath}/talk/adapeter.js`, () => {
|
|
25238
|
+
addJs(`${this.jSPlugin.staticPath}/talk/janus.js`, () => {
|
|
25239
|
+
addJs(`${this.jSPlugin.staticPath}/talk/tts-v4.js`, () => {
|
|
25222
25240
|
// 临时处理
|
|
25223
25241
|
window.EZUIKit["handleTalkError"] = {
|
|
25224
25242
|
handleTalkError: (err)=>{
|
|
@@ -26067,69 +26085,6 @@ class Theme {
|
|
|
26067
26085
|
PC端 & 直播 =》 pcLive
|
|
26068
26086
|
PC端 & 回放地址 => pcRec
|
|
26069
26087
|
*/
|
|
26070
|
-
// switch (matchEzopenUrl(jSPlugin.url).type) {
|
|
26071
|
-
// case 'live':
|
|
26072
|
-
// this.themeData = pcLiveData.data;
|
|
26073
|
-
// if (this.isMobile) {
|
|
26074
|
-
// this.themeData = mobileLiveData.data;
|
|
26075
|
-
// }
|
|
26076
|
-
// break;
|
|
26077
|
-
// case 'rec':
|
|
26078
|
-
// case 'cloud.rec':
|
|
26079
|
-
// this.themeData = pcRecData.data;
|
|
26080
|
-
// if (this.isMobile) {
|
|
26081
|
-
// this.themeData = mobileRecData.data;
|
|
26082
|
-
// }
|
|
26083
|
-
// break;
|
|
26084
|
-
// default:
|
|
26085
|
-
// break;
|
|
26086
|
-
// }
|
|
26087
|
-
// const videoId = jSPlugin.id;
|
|
26088
|
-
// this.header = defaultTheme.header;
|
|
26089
|
-
// this.footer = defaultTheme.footer;
|
|
26090
|
-
// if (!document.getElementById(`${this.jSPlugin.id}-headControl`)) {
|
|
26091
|
-
// const headerContainer = document.createElement('div');
|
|
26092
|
-
// headerContainer.setAttribute('id', `${this.jSPlugin.id}-headControl`);
|
|
26093
|
-
// headerContainer.setAttribute('class', 'head-message');
|
|
26094
|
-
// headerContainer.innerHTML = `<div id='${this.jSPlugin.id}}-headControl-left' style='display:flex'></div><div id='${this.jSPlugin.id}}-headControl-right' style='display:flex'></div>`;
|
|
26095
|
-
// var headerStyle = {
|
|
26096
|
-
// height: "48px",
|
|
26097
|
-
// "line-height": "48px",
|
|
26098
|
-
// display: "flex",
|
|
26099
|
-
// "justify-content": "space-between",
|
|
26100
|
-
// top: 0,
|
|
26101
|
-
// "z-index": 1,
|
|
26102
|
-
// background: "#000000",
|
|
26103
|
-
// color: "#FFFFFF",
|
|
26104
|
-
// width: "100%"
|
|
26105
|
-
// };
|
|
26106
|
-
// headerContainer.style = styleToString(headerStyle);
|
|
26107
|
-
// document.getElementById(`${videoId}-wrap`).insertBefore(headerContainer, document.getElementById(videoId));
|
|
26108
|
-
// }
|
|
26109
|
-
// if (!document.getElementById(`${this.jSPlugin.id}-ez-iframe-footer-container`)) {
|
|
26110
|
-
// const footerContainer = document.createElement('div');
|
|
26111
|
-
// footerContainer.setAttribute('id', `${this.jSPlugin.id}-ez-iframe-footer-container`);
|
|
26112
|
-
// footerContainer.setAttribute('class', 'ez-iframe-footer-container');
|
|
26113
|
-
// var footerStyle = {
|
|
26114
|
-
// "min-height": "48px",
|
|
26115
|
-
// "max-height": "96px",
|
|
26116
|
-
// "position": "relative",
|
|
26117
|
-
// "margin-top": "-48px",
|
|
26118
|
-
// display: "flex",
|
|
26119
|
-
// "flex-wrap": "wrap",
|
|
26120
|
-
// "justify-content": "space-between",
|
|
26121
|
-
// top: 0,
|
|
26122
|
-
// "z-index": 1,
|
|
26123
|
-
// color: "#FFFFFF",
|
|
26124
|
-
// width: "100%"
|
|
26125
|
-
// };
|
|
26126
|
-
// footerContainer.style = styleToString(footerStyle);
|
|
26127
|
-
// footerContainer.innerHTML = `<div id="${this.jSPlugin.id}-audioControls" style='display:flex;justify-content: space-between;height: 48px;width:100%;'><div id='${this.jSPlugin.id}-audioControls-left' style='display:flex'></div><div id='${this.jSPlugin.id}-audioControls-right' style='display:flex'></div></div>`;
|
|
26128
|
-
// insertAfter(footerContainer, document.getElementById(videoId));
|
|
26129
|
-
// }
|
|
26130
|
-
// if (!this.jSPlugin.inited) {
|
|
26131
|
-
// this.initThemeData();
|
|
26132
|
-
// }
|
|
26133
26088
|
if (this.jSPlugin.themeId) {
|
|
26134
26089
|
switch (this.jSPlugin.themeId) {
|
|
26135
26090
|
case 'pcLive':
|
|
@@ -26152,12 +26107,19 @@ class Theme {
|
|
|
26152
26107
|
this.initThemeData();
|
|
26153
26108
|
this.renderThemeData();
|
|
26154
26109
|
break;
|
|
26110
|
+
case 'themeData':
|
|
26111
|
+
this.themeData = this.jSPlugin.params.themeData;
|
|
26112
|
+
this.initThemeData();
|
|
26113
|
+
this.renderThemeData();
|
|
26155
26114
|
default:
|
|
26156
26115
|
this.fetchThemeData(this.jSPlugin.themeId);
|
|
26157
26116
|
break;
|
|
26158
26117
|
}
|
|
26159
26118
|
}
|
|
26160
|
-
|
|
26119
|
+
var isNeedRenderTimeLine = lodash.findIndex(this.themeData.header.btnList, (v)=>{
|
|
26120
|
+
return (v.iconId === 'cloudRec' && v.isrender === 1) || (v.iconId === 'rec' && v.isrender === 1) ;
|
|
26121
|
+
}) >= 0;
|
|
26122
|
+
if (isNeedRenderTimeLine) {
|
|
26161
26123
|
if (this.isMobile) {
|
|
26162
26124
|
this.Rec = new MobileRec(jSPlugin);
|
|
26163
26125
|
} else {
|
|
@@ -26167,7 +26129,7 @@ class Theme {
|
|
|
26167
26129
|
if (!this.jSPlugin.Talk) {
|
|
26168
26130
|
this.jSPlugin.Talk = new Talk(this.jSPlugin);
|
|
26169
26131
|
}
|
|
26170
|
-
if (
|
|
26132
|
+
if (matchEzopenUrl(jSPlugin.url).type === 'live') {
|
|
26171
26133
|
if (this.isMobile) {
|
|
26172
26134
|
this.MobilePtz = new MobilePtz(jSPlugin);
|
|
26173
26135
|
this.Ptz = new Ptz(jSPlugin);
|
|
@@ -26175,11 +26137,9 @@ class Theme {
|
|
|
26175
26137
|
this.Ptz = new Ptz(jSPlugin);
|
|
26176
26138
|
}
|
|
26177
26139
|
}
|
|
26178
|
-
//设备信息
|
|
26179
|
-
this.getDeviceInfo();
|
|
26180
26140
|
}
|
|
26181
26141
|
fetchThemeData(themeId) {
|
|
26182
|
-
const url =
|
|
26142
|
+
const url = `${this.jSPlugin.env.domain}/jssdk/ezopen/template/getDetail?accessToken=${this.jSPlugin.accessToken}&id=${themeId}`;
|
|
26183
26143
|
fetch(url, {
|
|
26184
26144
|
method: 'GET'
|
|
26185
26145
|
})
|
|
@@ -26260,7 +26220,7 @@ class Theme {
|
|
|
26260
26220
|
}
|
|
26261
26221
|
break;
|
|
26262
26222
|
case 'sound':
|
|
26263
|
-
if (`${this.jSPlugin.id}-sound`) {
|
|
26223
|
+
if (document.getElementById(`${this.jSPlugin.id}-sound`)) {
|
|
26264
26224
|
if (options[item]) {
|
|
26265
26225
|
document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[1].style = "display:inline-block";
|
|
26266
26226
|
document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[0].style = "display:none";
|
|
@@ -26351,9 +26311,16 @@ class Theme {
|
|
|
26351
26311
|
}
|
|
26352
26312
|
break;
|
|
26353
26313
|
case 'hd':
|
|
26354
|
-
if (
|
|
26355
|
-
document.getElementById(`${this.jSPlugin.id}-hd`)
|
|
26356
|
-
|
|
26314
|
+
if (options[item]) {
|
|
26315
|
+
if(document.getElementById(`${this.jSPlugin.id}-hd`)) {
|
|
26316
|
+
document.getElementById(`${this.jSPlugin.id}-hd-content`).children[1].children[0].style = "display:block";
|
|
26317
|
+
document.getElementById(`${this.jSPlugin.id}-hd-content`).children[1].children[1].style = "display:none";
|
|
26318
|
+
}
|
|
26319
|
+
} else {
|
|
26320
|
+
if(document.getElementById(`${this.jSPlugin.id}-hd`)) {
|
|
26321
|
+
document.getElementById(`${this.jSPlugin.id}-hd-content`).children[1].children[1].style = "display:block";
|
|
26322
|
+
document.getElementById(`${this.jSPlugin.id}-hd-content`).children[1].children[0].style = "display:none";
|
|
26323
|
+
}
|
|
26357
26324
|
}
|
|
26358
26325
|
break;
|
|
26359
26326
|
case 'cloudRec':
|
|
@@ -26807,8 +26774,7 @@ class Theme {
|
|
|
26807
26774
|
btnItem.onclick = (e) => {
|
|
26808
26775
|
const { hd } = this.decoderState.state;
|
|
26809
26776
|
// 选择清晰度选项时才触发事件
|
|
26810
|
-
|
|
26811
|
-
if (hd && e.target.id === 'select-sd') {
|
|
26777
|
+
if (hd && e.target.id === `${this.jSPlugin.id}-select-sd`) {
|
|
26812
26778
|
//decoder.changePlayUrl({ hd: false });
|
|
26813
26779
|
console.log("切换到标清");
|
|
26814
26780
|
this.jSPlugin.changePlayUrl({ hd: false });
|
|
@@ -27019,6 +26985,8 @@ class Theme {
|
|
|
27019
26985
|
window.addEventListener(item, (data) => fullscreenchange());
|
|
27020
26986
|
});
|
|
27021
26987
|
this.inited = true;
|
|
26988
|
+
//设备信息
|
|
26989
|
+
this.getDeviceInfo();
|
|
27022
26990
|
}
|
|
27023
26991
|
getDeviceInfo() {
|
|
27024
26992
|
const deviceAPISuccess = (data) => {
|
|
@@ -27042,6 +27010,43 @@ class Theme {
|
|
|
27042
27010
|
}
|
|
27043
27011
|
}
|
|
27044
27012
|
|
|
27013
|
+
class Monitor {
|
|
27014
|
+
constructor(params) {
|
|
27015
|
+
this.params = params;
|
|
27016
|
+
this.state = {
|
|
27017
|
+
};
|
|
27018
|
+
}
|
|
27019
|
+
dclog(dclogObj) {
|
|
27020
|
+
const { params } = this;
|
|
27021
|
+
var url = "https://log.ys7.com/statistics.do?";
|
|
27022
|
+
if(params.env) {
|
|
27023
|
+
switch(params.env){
|
|
27024
|
+
case 'test12':
|
|
27025
|
+
url = "https://test12dclog.ys7.com/statistics.do?";
|
|
27026
|
+
break;
|
|
27027
|
+
case 'online':
|
|
27028
|
+
break;
|
|
27029
|
+
default:
|
|
27030
|
+
url = params.env;
|
|
27031
|
+
break;
|
|
27032
|
+
}
|
|
27033
|
+
}
|
|
27034
|
+
var obj = Object.assign({}, { systemName: "open_website_monitor" }, { bn: "ezuikit-js" }, dclogObj, {un:dclogObj.url}, { st: new Date().getTime(), h: window.location.pathname }); // usr_name 更改为un,兼容旧
|
|
27035
|
+
Object.keys(obj).forEach(function(item, index){
|
|
27036
|
+
var value = obj[item];
|
|
27037
|
+
if (typeof (obj[item]) === 'string') {
|
|
27038
|
+
value = obj[item].replace('%', '%25'); // decodeURIComponent 无法解析%
|
|
27039
|
+
}
|
|
27040
|
+
if (typeof (obj[item]) === 'undefined') {
|
|
27041
|
+
return;
|
|
27042
|
+
}
|
|
27043
|
+
url += "".concat(index === 0 ? '' : '&').concat(item, "=").concat(encodeURIComponent(value));
|
|
27044
|
+
});
|
|
27045
|
+
var img = new Image();
|
|
27046
|
+
img.src = url;
|
|
27047
|
+
}
|
|
27048
|
+
}
|
|
27049
|
+
|
|
27045
27050
|
/**
|
|
27046
27051
|
* EZUIKitPlayer for npm
|
|
27047
27052
|
*/
|
|
@@ -28639,46 +28644,146 @@ var EZUIKitV3$1 = EZUIKitV3;
|
|
|
28639
28644
|
|
|
28640
28645
|
/* eslint-disable valid-jsdoc */
|
|
28641
28646
|
|
|
28647
|
+
// iframe模板 - 兼容旧版本
|
|
28648
|
+
const matchTemplate = (templateName, params) => {
|
|
28649
|
+
const IFRAMETEMPLATE = ['simple', 'standard', 'security', 'voice', 'theme'];
|
|
28650
|
+
const LOCALTEMPLATE = ['pcLive', 'pcRec', 'mobileLive', 'mobileRec', 'noData', ''];
|
|
28651
|
+
if (typeof templateName === 'undefined') {
|
|
28652
|
+
if(params.themeData) {
|
|
28653
|
+
return {
|
|
28654
|
+
templateType: 'themeData',
|
|
28655
|
+
templateId: 'themeData'
|
|
28656
|
+
}
|
|
28657
|
+
}
|
|
28658
|
+
return {
|
|
28659
|
+
templateType: 'local',
|
|
28660
|
+
templateId: ''
|
|
28661
|
+
}
|
|
28662
|
+
} if (typeof templateName === 'string') {
|
|
28663
|
+
|
|
28664
|
+
if (templateName.length === 32) {
|
|
28665
|
+
return {
|
|
28666
|
+
templateType: 'remote',
|
|
28667
|
+
templateId: templateName
|
|
28668
|
+
}
|
|
28669
|
+
} else if (IFRAMETEMPLATE.indexOf(templateName) !== -1) {
|
|
28670
|
+
// 精简版且不使用头部,底部,仅播放视频,建议使用按需加载避免iframe内存额外消耗
|
|
28671
|
+
if (templateName === 'simple' && typeof params.header === 'undefined' && typeof params.footer === 'undefined') {
|
|
28672
|
+
return {
|
|
28673
|
+
templateType: 'local',
|
|
28674
|
+
templateId: ''
|
|
28675
|
+
}
|
|
28676
|
+
}
|
|
28677
|
+
return {
|
|
28678
|
+
templateType: 'iframe',
|
|
28679
|
+
templateId: templateName
|
|
28680
|
+
}
|
|
28681
|
+
} else if (LOCALTEMPLATE.indexOf(templateName) !== -1) {
|
|
28682
|
+
return {
|
|
28683
|
+
templateType: 'local',
|
|
28684
|
+
templateId: templateName
|
|
28685
|
+
}
|
|
28686
|
+
}
|
|
28687
|
+
}
|
|
28688
|
+
};
|
|
28689
|
+
|
|
28642
28690
|
class EZUIKitPlayer {
|
|
28643
28691
|
constructor(params) {
|
|
28644
28692
|
const { autoplay = true } = params;
|
|
28645
28693
|
this.params = params;
|
|
28646
|
-
|
|
28647
|
-
|
|
28648
|
-
|
|
28649
|
-
|
|
28650
|
-
|
|
28651
|
-
|
|
28652
|
-
|
|
28653
|
-
|
|
28654
|
-
themeInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.themeInit || false,
|
|
28655
|
-
talkInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.talkInit || false
|
|
28656
|
-
}}
|
|
28694
|
+
window.EZUIKit[params.id] = {
|
|
28695
|
+
state: {
|
|
28696
|
+
EZUIKitPlayer: {
|
|
28697
|
+
init: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.init || false,
|
|
28698
|
+
themeInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.themeInit || false,
|
|
28699
|
+
talkInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.talkInit || false
|
|
28700
|
+
}
|
|
28701
|
+
}
|
|
28657
28702
|
};
|
|
28658
|
-
if (
|
|
28703
|
+
if (matchTemplate(this.params.template, params).templateType !== 'iframe') {
|
|
28704
|
+
this.Monitor = new Monitor({
|
|
28705
|
+
env: !(typeof params.disableMonitor !== 'undefined' && params.disableMonitor) ? 'online' : 'test12',
|
|
28706
|
+
});
|
|
28659
28707
|
this.id = params.id;
|
|
28660
28708
|
this.width = params.width;
|
|
28661
28709
|
this.height = params.height;
|
|
28662
28710
|
this.url = params.url;
|
|
28663
28711
|
this.accessToken = params.accessToken;
|
|
28664
|
-
this.themeId = params.
|
|
28712
|
+
this.themeId = matchTemplate(params.template, params).templateId;
|
|
28665
28713
|
this.id = params.id;
|
|
28666
|
-
this.audio =
|
|
28667
|
-
|
|
28668
|
-
|
|
28669
|
-
|
|
28670
|
-
|
|
28671
|
-
|
|
28672
|
-
|
|
28673
|
-
|
|
28674
|
-
|
|
28675
|
-
|
|
28676
|
-
|
|
28677
|
-
|
|
28678
|
-
|
|
28679
|
-
|
|
28680
|
-
|
|
28681
|
-
|
|
28714
|
+
this.audio = true;
|
|
28715
|
+
this.poster = params.poster;
|
|
28716
|
+
this.speed = 1;
|
|
28717
|
+
this.staticPath = "https://open.ys7.com/assets/ezuikit_v4.0";
|
|
28718
|
+
if (typeof params.staticPath === 'string') {
|
|
28719
|
+
this.staticPath = params.staticPath;
|
|
28720
|
+
}
|
|
28721
|
+
if(typeof params.audio !== 'undefined') {
|
|
28722
|
+
this.audio = params.audio;
|
|
28723
|
+
}
|
|
28724
|
+
addJs(`${this.staticPath}/js/AudioRenderer.js`, () => {
|
|
28725
|
+
addJs(`${this.staticPath}/js/SuperRender_10.js`, () => {
|
|
28726
|
+
addJs(`${this.staticPath}/js/jsPlugin-4.0.2.min.js`, () => {
|
|
28727
|
+
if (autoplay) {
|
|
28728
|
+
this.initTime = new Date().getTime();
|
|
28729
|
+
this.Monitor.dclog({
|
|
28730
|
+
url: this.url,
|
|
28731
|
+
action: 0,
|
|
28732
|
+
text: 'startInit',
|
|
28733
|
+
});
|
|
28734
|
+
var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
|
|
28735
|
+
var getRealUrlPromise = this._getRealUrlPromise(params.accessToken, params.url);
|
|
28736
|
+
Promise.all([initEZUIKitPlayerPromise, getRealUrlPromise]).then(values => {
|
|
28737
|
+
console.log("values", values);
|
|
28738
|
+
if (values[1]) {
|
|
28739
|
+
this._pluginPlay(values[1],
|
|
28740
|
+
() => {
|
|
28741
|
+
console.log("自动播放成功");
|
|
28742
|
+
this.Monitor.dclog({
|
|
28743
|
+
url: this.url,
|
|
28744
|
+
action: 202,
|
|
28745
|
+
d: new Date().getTime() - this.initTime,
|
|
28746
|
+
text: 'autoPlaySuccess'
|
|
28747
|
+
});
|
|
28748
|
+
},
|
|
28749
|
+
() => {
|
|
28750
|
+
console.log("自动播放失败");
|
|
28751
|
+
this.Monitor.dclog({
|
|
28752
|
+
url: this.url,
|
|
28753
|
+
action: 402,
|
|
28754
|
+
d: new Date().getTime() - this.initTime,
|
|
28755
|
+
text: 'autoPlayError'
|
|
28756
|
+
});
|
|
28757
|
+
},
|
|
28758
|
+
);
|
|
28759
|
+
}
|
|
28760
|
+
window.EZUIKit[params.id].state.EZUIKitPlayer.init = true;
|
|
28761
|
+
if (document.getElementById(`${params.id}canvas_draw0`)) {
|
|
28762
|
+
document.getElementById(`${params.id}canvas_draw0`).style.border = "none";
|
|
28763
|
+
}
|
|
28764
|
+
});
|
|
28765
|
+
} else {
|
|
28766
|
+
this.initTime = new Date().getTime();
|
|
28767
|
+
this.Monitor.dclog({
|
|
28768
|
+
url: this.url,
|
|
28769
|
+
action: 0,
|
|
28770
|
+
text: 'startInit',
|
|
28771
|
+
});
|
|
28772
|
+
var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
|
|
28773
|
+
initEZUIKitPlayerPromise.then((data) => {
|
|
28774
|
+
console.log("初始化成功", data);
|
|
28775
|
+
window.EZUIKit[params.id].state.EZUIKitPlayer.init = true;
|
|
28776
|
+
if (document.getElementById(`${params.id}canvas_draw0`)) {
|
|
28777
|
+
document.getElementById(`${params.id}canvas_draw0`).style.border = "none";
|
|
28778
|
+
}
|
|
28779
|
+
this.Monitor.dclog({
|
|
28780
|
+
url: this.url,
|
|
28781
|
+
action: 201,
|
|
28782
|
+
d: new Date().getTime() - this.initTime,
|
|
28783
|
+
text: 'initSuccess',
|
|
28784
|
+
});
|
|
28785
|
+
});
|
|
28786
|
+
}
|
|
28682
28787
|
});
|
|
28683
28788
|
});
|
|
28684
28789
|
});
|
|
@@ -28691,7 +28796,7 @@ class EZUIKitPlayer {
|
|
|
28691
28796
|
}
|
|
28692
28797
|
}
|
|
28693
28798
|
initEZUIKitPlayer(params) {
|
|
28694
|
-
const { id,
|
|
28799
|
+
const { id, width = 600, height = 400 } = params;
|
|
28695
28800
|
if (!document.getElementById(`${id}-wrap`)) {
|
|
28696
28801
|
document.getElementById(id).style = `display:inline-block;width:${width}px;height:${height}px;`;
|
|
28697
28802
|
var wapDom = document.createElement("div");
|
|
@@ -28710,6 +28815,7 @@ class EZUIKitPlayer {
|
|
|
28710
28815
|
iMaxSplit: 1,
|
|
28711
28816
|
iCurrentSplit: 1,
|
|
28712
28817
|
szBasePath: "",
|
|
28818
|
+
staticPath: params.staticPath,
|
|
28713
28819
|
oStyle: {
|
|
28714
28820
|
border: "none",
|
|
28715
28821
|
background: "#000000"
|
|
@@ -28748,8 +28854,10 @@ class EZUIKitPlayer {
|
|
|
28748
28854
|
},
|
|
28749
28855
|
windowFullCcreenChange: function (bFull) {
|
|
28750
28856
|
},
|
|
28751
|
-
firstFrameDisplay:
|
|
28857
|
+
firstFrameDisplay: (iWndIndex, iWidth, iHeight) => {
|
|
28858
|
+
console.log(iWidth, iHeight);
|
|
28752
28859
|
jSPlugin.JS_SetCanFullScreen(false);
|
|
28860
|
+
this.pluginStatus.loadingClear();
|
|
28753
28861
|
},
|
|
28754
28862
|
performanceLack: function () {
|
|
28755
28863
|
},
|
|
@@ -28757,7 +28865,7 @@ class EZUIKitPlayer {
|
|
|
28757
28865
|
}
|
|
28758
28866
|
};
|
|
28759
28867
|
// 增加视频容器
|
|
28760
|
-
var pluginStatus = new Status(id);
|
|
28868
|
+
var pluginStatus = new Status(this, id);
|
|
28761
28869
|
pluginStatus.loadingStart(id);
|
|
28762
28870
|
pluginStatus.loadingSetText({ text: '初始化播放器完成' });
|
|
28763
28871
|
this.env = {
|
|
@@ -28768,7 +28876,7 @@ class EZUIKitPlayer {
|
|
|
28768
28876
|
}
|
|
28769
28877
|
this.errorHander = new Code();
|
|
28770
28878
|
this.jSPlugin = jSPlugin;
|
|
28771
|
-
if (themeId && !window.EZUIKit[params.id].state.EZUIKitPlayer.themeInit) {
|
|
28879
|
+
if (this.themeId && !window.EZUIKit[params.id].state.EZUIKitPlayer.themeInit) {
|
|
28772
28880
|
this.Theme = new Theme(this, id);
|
|
28773
28881
|
window.EZUIKit[params.id].state.EZUIKitPlayer.themeInit = true;
|
|
28774
28882
|
}
|
|
@@ -29082,64 +29190,99 @@ class EZUIKitPlayer {
|
|
|
29082
29190
|
return new Date(date.replace(/-/g, '/')).getTime();
|
|
29083
29191
|
}
|
|
29084
29192
|
}
|
|
29085
|
-
|
|
29193
|
+
_pluginPlay(data, successCallback, errorCallback) {
|
|
29194
|
+
console.log("get real url result ===", data);
|
|
29195
|
+
function getPlayParams(url) {
|
|
29196
|
+
var websocketConnectUrl = url.split('?')[0].replace('/live', '').replace('/playback', '');
|
|
29197
|
+
var websocketStreamingParam = (url.indexOf('/live') === -1 ? (url.indexOf('cloudplayback') !== -1 ? '/cloudplayback?' : '/playback?') : '/live?') + url.split('?')[1];
|
|
29198
|
+
if (websocketStreamingParam.indexOf('/playback') !== -1) {
|
|
29199
|
+
websocketStreamingParam = websocketStreamingParam.replace("stream=2", 'stream=1');
|
|
29200
|
+
}
|
|
29201
|
+
// 本地回放仅支持主码流
|
|
29202
|
+
return {
|
|
29203
|
+
websocketConnectUrl: websocketConnectUrl,
|
|
29204
|
+
websocketStreamingParam: websocketStreamingParam
|
|
29205
|
+
};
|
|
29206
|
+
}
|
|
29207
|
+
var wsUrl = getPlayParams(data).websocketConnectUrl;
|
|
29208
|
+
if (this.env && this.env.wsUrl) {
|
|
29209
|
+
wsUrl = this.env.wsUrl;
|
|
29210
|
+
}
|
|
29211
|
+
var wsParams = {
|
|
29212
|
+
playURL: getPlayParams(data).websocketStreamingParam
|
|
29213
|
+
};
|
|
29214
|
+
|
|
29215
|
+
this.jSPlugin.JS_Play(wsUrl, wsParams, 0).then(() => {
|
|
29216
|
+
console.log("播放成功");
|
|
29217
|
+
if (this.Theme) {
|
|
29218
|
+
this.Theme.setDecoderState({ play: true });
|
|
29219
|
+
}
|
|
29220
|
+
if (this.audio) {
|
|
29221
|
+
setTimeout(() => {
|
|
29222
|
+
this.openSound();
|
|
29223
|
+
}, 500);
|
|
29224
|
+
}
|
|
29225
|
+
if (typeof this.params.handleSuccess === 'function') {
|
|
29226
|
+
this.params.handleSuccess({
|
|
29227
|
+
retcode: 0,
|
|
29228
|
+
id: this.params.id,
|
|
29229
|
+
type: "handleSuccess"
|
|
29230
|
+
});
|
|
29231
|
+
}
|
|
29232
|
+
successCallback();
|
|
29233
|
+
this.Monitor.dclog({
|
|
29234
|
+
url: this.url,
|
|
29235
|
+
action: 211,
|
|
29236
|
+
d: new Date().getTime() - this.playStartTime,
|
|
29237
|
+
text: 'startPlaySuccess'
|
|
29238
|
+
});
|
|
29239
|
+
}, (err) => {
|
|
29240
|
+
var errorInfo = this.errorHander.matchErrorInfo(err.oError.errorCode);
|
|
29241
|
+
var msg = errorInfo ? errorInfo.description : '播放失败,请检查设备及客户端网络';
|
|
29242
|
+
this.pluginStatus.loadingSetText({
|
|
29243
|
+
text: msg,
|
|
29244
|
+
color: 'red'
|
|
29245
|
+
});
|
|
29246
|
+
if (typeof this.params.handleError === 'function') {
|
|
29247
|
+
this.params.handleError({
|
|
29248
|
+
retcode: err.oError.errorCode,
|
|
29249
|
+
msg: msg,
|
|
29250
|
+
id: this.params.id,
|
|
29251
|
+
type: "handleError"
|
|
29252
|
+
});
|
|
29253
|
+
}
|
|
29254
|
+
errorCallback();
|
|
29255
|
+
this.Monitor.dclog({
|
|
29256
|
+
url: this.url,
|
|
29257
|
+
action: 411,
|
|
29258
|
+
d: new Date().getTime() - this.playStartTime,
|
|
29259
|
+
text: 'startPlayError'
|
|
29260
|
+
});
|
|
29261
|
+
});
|
|
29262
|
+
}
|
|
29263
|
+
play(options) {
|
|
29264
|
+
this.playStartTime = new Date().getTime();
|
|
29265
|
+
this.Monitor.dclog({
|
|
29266
|
+
url: this.url,
|
|
29267
|
+
action: 1,
|
|
29268
|
+
d: new Date().getTime() - this.initTime,
|
|
29269
|
+
text: 'startPlay'
|
|
29270
|
+
});
|
|
29271
|
+
if(options) {
|
|
29272
|
+
if(typeof options.url === 'string') {
|
|
29273
|
+
this.url = options.url;
|
|
29274
|
+
}
|
|
29275
|
+
if(typeof options.accessToken === 'string') {
|
|
29276
|
+
this.accessToken = options.accessToken;
|
|
29277
|
+
}
|
|
29278
|
+
if(this.Theme && (typeof options.url === 'string' || typeof options.accessToken === 'string')) {
|
|
29279
|
+
this.Theme.getDeviceInfo();
|
|
29280
|
+
}
|
|
29281
|
+
}
|
|
29086
29282
|
const promise = new Promise((resolve, reject) => {
|
|
29087
29283
|
this._getRealUrlPromise(this.accessToken, this.url)
|
|
29088
29284
|
.then((data) => {
|
|
29089
|
-
|
|
29090
|
-
function getPlayParams(url) {
|
|
29091
|
-
var websocketConnectUrl = url.split('?')[0].replace('/live', '').replace('/playback', '');
|
|
29092
|
-
var websocketStreamingParam = (url.indexOf('/live') === -1 ? (url.indexOf('cloudplayback') !== -1 ? '/cloudplayback?' : '/playback?') : '/live?') + url.split('?')[1];
|
|
29093
|
-
if (websocketStreamingParam.indexOf('/playback') !== -1) {
|
|
29094
|
-
websocketStreamingParam = websocketStreamingParam.replace("stream=2", 'stream=1');
|
|
29095
|
-
}
|
|
29096
|
-
// 本地回放仅支持主码流
|
|
29097
|
-
return {
|
|
29098
|
-
websocketConnectUrl: websocketConnectUrl,
|
|
29099
|
-
websocketStreamingParam: websocketStreamingParam
|
|
29100
|
-
};
|
|
29101
|
-
}
|
|
29102
|
-
var wsUrl = getPlayParams(data).websocketConnectUrl;
|
|
29103
|
-
var wsParams = {
|
|
29104
|
-
playURL: getPlayParams(data).websocketStreamingParam
|
|
29105
|
-
};
|
|
29106
|
-
|
|
29107
|
-
this.jSPlugin.JS_Play(wsUrl, wsParams, 0).then(() => {
|
|
29108
|
-
console.log("播放成功");
|
|
29109
|
-
this.pluginStatus.loadingClear();
|
|
29110
|
-
if (this.Theme) {
|
|
29111
|
-
this.Theme.setDecoderState({ play: true });
|
|
29112
|
-
}
|
|
29113
|
-
if (this.audio) {
|
|
29114
|
-
setTimeout(() => {
|
|
29115
|
-
this.openSound();
|
|
29116
|
-
}, 500);
|
|
29117
|
-
}
|
|
29118
|
-
if (typeof this.params.handleSuccess === 'function') {
|
|
29119
|
-
this.params.handleSuccess({
|
|
29120
|
-
retcode: 0,
|
|
29121
|
-
id: this.params.id,
|
|
29122
|
-
type: "handleSuccess"
|
|
29123
|
-
});
|
|
29124
|
-
}
|
|
29125
|
-
resolve(true);
|
|
29126
|
-
}, (err) => {
|
|
29127
|
-
var errorInfo = this.errorHander.matchErrorInfo(err.oError.errorCode);
|
|
29128
|
-
var msg = errorInfo ? errorInfo.description : '播放失败,请检查设备及客户端网络';
|
|
29129
|
-
this.pluginStatus.loadingSetText({
|
|
29130
|
-
text: msg,
|
|
29131
|
-
color: 'red'
|
|
29132
|
-
});
|
|
29133
|
-
if (typeof this.params.handleError === 'function') {
|
|
29134
|
-
this.params.handleError({
|
|
29135
|
-
retcode: err.oError.errorCode,
|
|
29136
|
-
msg: msg,
|
|
29137
|
-
id: this.params.id,
|
|
29138
|
-
type: "handleError"
|
|
29139
|
-
});
|
|
29140
|
-
}
|
|
29141
|
-
reject(false);
|
|
29142
|
-
});
|
|
29285
|
+
this._pluginPlay(data, () => resolve(true), () => reject(false));
|
|
29143
29286
|
})
|
|
29144
29287
|
.catch((err) => {
|
|
29145
29288
|
var msg = err.msg ? err.msg : '播放失败,请检查设备及客户端网络';
|
|
@@ -29255,28 +29398,45 @@ class EZUIKitPlayer {
|
|
|
29255
29398
|
return promise;
|
|
29256
29399
|
}
|
|
29257
29400
|
getOSDTime() {
|
|
29258
|
-
var promise = new Promise((resolve,reject) => {
|
|
29401
|
+
var promise = new Promise((resolve, reject) => {
|
|
29259
29402
|
this.jSPlugin.JS_GetOSDTime(0)
|
|
29260
|
-
.then((data)=>{
|
|
29403
|
+
.then((data) => {
|
|
29261
29404
|
resolve({
|
|
29262
29405
|
code: 0,
|
|
29263
29406
|
retcode: 0,
|
|
29264
29407
|
data: data
|
|
29265
29408
|
});
|
|
29409
|
+
// 兼容旧版本callback
|
|
29410
|
+
if (typeof this.params.getOSDTimeCallBack === 'function') {
|
|
29411
|
+
this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: 0, data: data});
|
|
29412
|
+
}
|
|
29266
29413
|
})
|
|
29267
|
-
.catch(err=>{
|
|
29414
|
+
.catch(err => {
|
|
29268
29415
|
reject({
|
|
29269
29416
|
code: -1,
|
|
29270
29417
|
retcode: -1,
|
|
29271
29418
|
data: err
|
|
29272
29419
|
});
|
|
29420
|
+
// 兼容旧版本callback
|
|
29421
|
+
if (typeof this.params.getOSDTimeCallBack === 'function') {
|
|
29422
|
+
this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: -1,data: -1 });
|
|
29423
|
+
}
|
|
29273
29424
|
});
|
|
29274
29425
|
});
|
|
29275
29426
|
return promise;
|
|
29276
29427
|
}
|
|
29277
29428
|
capturePicture(name, callback = false) {
|
|
29278
|
-
var capturePictureRT = this.jSPlugin.JS_CapturePicture(0, name, "JPEG", callback);
|
|
29429
|
+
var capturePictureRT = this.jSPlugin.JS_CapturePicture(0, name, "JPEG", callback, !!callback);
|
|
29279
29430
|
if (isPromise(capturePictureRT)) {
|
|
29431
|
+
// 兼容旧版本callback
|
|
29432
|
+
if (typeof this.params.capturePictureCallBack === 'function') {
|
|
29433
|
+
capturePictureRT.then(() => {
|
|
29434
|
+
this.params.capturePictureCallBack({ id: this.id, type: 'capturePicture', code: 0 });
|
|
29435
|
+
})
|
|
29436
|
+
.catch(() => {
|
|
29437
|
+
this.params.capturePictureCallBack({ id: this.id, type: 'capturePicture', code: -1 });
|
|
29438
|
+
});
|
|
29439
|
+
}
|
|
29280
29440
|
return capturePictureRT;
|
|
29281
29441
|
}
|
|
29282
29442
|
return new Promise(function (resolve) {
|
|
@@ -29286,6 +29446,15 @@ class EZUIKitPlayer {
|
|
|
29286
29446
|
startSave(name) {
|
|
29287
29447
|
var startSaveRT = this.jSPlugin.JS_StartSave(0, name);
|
|
29288
29448
|
if (isPromise(startSaveRT)) {
|
|
29449
|
+
// 兼容旧版本callback
|
|
29450
|
+
if (typeof this.params.startSaveCallBack === 'function') {
|
|
29451
|
+
startSaveRT.then(() => {
|
|
29452
|
+
this.params.startSaveCallBack({ id: this.id, type: 'startSave', code: 0 });
|
|
29453
|
+
})
|
|
29454
|
+
.catch(() => {
|
|
29455
|
+
this.params.startSaveCallBack({ id: this.id, type: 'startSave', code: -1 });
|
|
29456
|
+
});
|
|
29457
|
+
}
|
|
29289
29458
|
return startSaveRT;
|
|
29290
29459
|
}
|
|
29291
29460
|
if (this.Theme) {
|
|
@@ -29298,6 +29467,15 @@ class EZUIKitPlayer {
|
|
|
29298
29467
|
stopSave() {
|
|
29299
29468
|
var stopSaveRT = this.jSPlugin.JS_StopSave(0);
|
|
29300
29469
|
if (isPromise(stopSaveRT)) {
|
|
29470
|
+
// 兼容旧版本callback
|
|
29471
|
+
if (typeof this.params.startSaveCallBack === 'function') {
|
|
29472
|
+
stopSaveRT.then(() => {
|
|
29473
|
+
this.params.stopSaveCallBack({ id: this.id, type: 'stopSave', code: 0 });
|
|
29474
|
+
})
|
|
29475
|
+
.catch(() => {
|
|
29476
|
+
this.params.stopSaveCallBack({ id: this.id, type: 'stopSave', code: -1 });
|
|
29477
|
+
});
|
|
29478
|
+
}
|
|
29301
29479
|
return stopSaveRT;
|
|
29302
29480
|
}
|
|
29303
29481
|
if (this.Theme) {
|
|
@@ -29316,6 +29494,10 @@ class EZUIKitPlayer {
|
|
|
29316
29494
|
if (this.Theme) {
|
|
29317
29495
|
this.Theme.setDecoderState({ sound: true });
|
|
29318
29496
|
}
|
|
29497
|
+
// 兼容旧版本callback
|
|
29498
|
+
if (typeof this.params.openSoundCallBack === 'function') {
|
|
29499
|
+
this.params.openSoundCallBack({ id: this.id, type: 'openSound', code: openSoundRT });
|
|
29500
|
+
}
|
|
29319
29501
|
return new Promise(function (resolve) {
|
|
29320
29502
|
resolve(openSoundRT);
|
|
29321
29503
|
});
|
|
@@ -29328,6 +29510,10 @@ class EZUIKitPlayer {
|
|
|
29328
29510
|
if (this.Theme) {
|
|
29329
29511
|
this.Theme.setDecoderState({ sound: false });
|
|
29330
29512
|
}
|
|
29513
|
+
// 兼容旧版本callback
|
|
29514
|
+
if (typeof this.params.closeSoundCallBack === 'function') {
|
|
29515
|
+
this.params.closeSoundCallBack({ id: this.id, type: 'closeSound', code: closeSoundRT });
|
|
29516
|
+
}
|
|
29331
29517
|
return new Promise(function (resolve) {
|
|
29332
29518
|
resolve(closeSoundRT);
|
|
29333
29519
|
});
|
|
@@ -29350,17 +29536,134 @@ class EZUIKitPlayer {
|
|
|
29350
29536
|
resolve(closeZoomRT);
|
|
29351
29537
|
});
|
|
29352
29538
|
}
|
|
29539
|
+
setPoster(url) {
|
|
29540
|
+
this.pluginStatus.setPoster(url);
|
|
29541
|
+
}
|
|
29353
29542
|
reSize(width, height) {
|
|
29354
29543
|
this.width = width;
|
|
29355
29544
|
this.height = height;
|
|
29356
|
-
document.getElementById(`${this.id}-wrap`).style
|
|
29545
|
+
document.getElementById(`${this.id}-wrap`).style = `width:${width}px;position:relative;`;
|
|
29357
29546
|
this.jSPlugin.JS_Resize(width, height);
|
|
29358
29547
|
}
|
|
29548
|
+
fast() {
|
|
29549
|
+
var speed = this.speed;
|
|
29550
|
+
if (speed === 1) {
|
|
29551
|
+
speed = 2;
|
|
29552
|
+
} else if (speed === 2) {
|
|
29553
|
+
speed = 4;
|
|
29554
|
+
} else {
|
|
29555
|
+
if (typeof this.params.handleError === 'function') {
|
|
29556
|
+
this.params.handleError({
|
|
29557
|
+
msg: "播放速度最大为4倍速度",
|
|
29558
|
+
retcode: 1003,
|
|
29559
|
+
id: this.id,
|
|
29560
|
+
type: "handleError"
|
|
29561
|
+
});
|
|
29562
|
+
}
|
|
29563
|
+
}
|
|
29564
|
+
var fastRT = this.jSPlugin.JS_Fast(0);
|
|
29565
|
+
if (isPromise(fastRT)) {
|
|
29566
|
+
this.speed = speed;
|
|
29567
|
+
return fastRT;
|
|
29568
|
+
}
|
|
29569
|
+
return new Promise(function (resolve) {
|
|
29570
|
+
this.speed = speed;
|
|
29571
|
+
resolve(fastRT);
|
|
29572
|
+
});
|
|
29573
|
+
}
|
|
29574
|
+
slow() {
|
|
29575
|
+
var speed = this.speed;
|
|
29576
|
+
if (speed === 4) {
|
|
29577
|
+
speed = 2;
|
|
29578
|
+
} else if (speed === 2) {
|
|
29579
|
+
speed = 1;
|
|
29580
|
+
} else {
|
|
29581
|
+
if (typeof this.params.handleError === 'function') {
|
|
29582
|
+
this.params.handleError({
|
|
29583
|
+
msg: "播放速度最小为1倍速度",
|
|
29584
|
+
retcode: 1003,
|
|
29585
|
+
id: this.id,
|
|
29586
|
+
type: "handleError"
|
|
29587
|
+
});
|
|
29588
|
+
}
|
|
29589
|
+
}
|
|
29590
|
+
var slowRT = this.jSPlugin.JS_Slow(0);
|
|
29591
|
+
console.log("slowRT", slowRT);
|
|
29592
|
+
if (isPromise(slowRT)) {
|
|
29593
|
+
this.speed = speed;
|
|
29594
|
+
return slowRT;
|
|
29595
|
+
}
|
|
29596
|
+
return new Promise(function (resolve) {
|
|
29597
|
+
this.speed = speed;
|
|
29598
|
+
resolve(slowRT);
|
|
29599
|
+
});
|
|
29600
|
+
}
|
|
29601
|
+
seek(startTime, endTime) {
|
|
29602
|
+
var url = this.url;
|
|
29603
|
+
var currentDay = (getQueryString(url, 'begin') || new Date().Format('yyyyMMdd')).substr(0,8);
|
|
29604
|
+
endTime = formatRecTime(currentDay,'235959');
|
|
29605
|
+
if(startTime.length === 6) {
|
|
29606
|
+
startTime = formatRecTime(currentDay,startTime);
|
|
29607
|
+
} else if (startTime.length === 16) {
|
|
29608
|
+
if(startTime.substr(0,8) !== currentDay) {
|
|
29609
|
+
this.params.handleError({
|
|
29610
|
+
msg: "seek时间不能跨日期",
|
|
29611
|
+
retcode: -1,
|
|
29612
|
+
id: this.id,
|
|
29613
|
+
type: "handleError"
|
|
29614
|
+
});
|
|
29615
|
+
return false;
|
|
29616
|
+
}
|
|
29617
|
+
} else {
|
|
29618
|
+
this.params.handleError({
|
|
29619
|
+
msg: "seek时间格式错误",
|
|
29620
|
+
retcode: -1,
|
|
29621
|
+
id: this.id,
|
|
29622
|
+
type: "handleError"
|
|
29623
|
+
});
|
|
29624
|
+
return false;
|
|
29625
|
+
}
|
|
29626
|
+
// 格式化回放时间
|
|
29627
|
+
function formatRecTime(time, defaultTime) {
|
|
29628
|
+
// 用户格式 无需更改 => 20182626T000000Z
|
|
29629
|
+
// return time
|
|
29630
|
+
// 用户格式需要更改
|
|
29631
|
+
//用户时间长度为 14 20181226000000 =》 20181226000000
|
|
29632
|
+
// 用户长度为12 201812260000 =》 201812260000 + defaultTime后面2位
|
|
29633
|
+
// 用户长度为10 2018122600 =》 201812260000 + defaultTime后面4位
|
|
29634
|
+
// 用户长度为8 20181226 =》 201812260000 + defaultTime后面6位
|
|
29635
|
+
// 结果 20181226000000 14位
|
|
29636
|
+
// 插入 TZ
|
|
29637
|
+
var reg = /^[0-9]{8}T[0-9]{6}Z$/;
|
|
29638
|
+
if (reg.test(time)) { // 用户格式 无需更改 => 20182626T000000Z
|
|
29639
|
+
return time;
|
|
29640
|
+
} else if (/[0-9]{8,14}/.test(time)) {
|
|
29641
|
+
var start = 6 - (14 - time.length);
|
|
29642
|
+
var end = defaultTime.length;
|
|
29643
|
+
var standardTime = time + defaultTime.substring(start, end);
|
|
29644
|
+
return standardTime.slice(0, 8) + 'T' + standardTime.slice(8) + 'Z';
|
|
29645
|
+
} else {
|
|
29646
|
+
throw new Error('回放时间格式有误,请确认');
|
|
29647
|
+
}
|
|
29648
|
+
}
|
|
29649
|
+
var seekRT = this.jSPlugin.JS_Seek(0, startTime, endTime);
|
|
29650
|
+
console.log("seekRT", seekRT);
|
|
29651
|
+
if (isPromise(seekRT)) {
|
|
29652
|
+
return seekRT;
|
|
29653
|
+
}
|
|
29654
|
+
return new Promise(function (resolve) {
|
|
29655
|
+
resolve(seekRT);
|
|
29656
|
+
});
|
|
29657
|
+
}
|
|
29359
29658
|
fullScreen() {
|
|
29360
29659
|
var promise = requestFullScreenPromise(document.getElementById(`${this.id}`));
|
|
29361
29660
|
promise.then((data) => {
|
|
29362
29661
|
console.log("全屏promise", window.screen.availWidth);
|
|
29363
29662
|
this.jSPlugin.JS_Resize(window.screen.availWidth, window.screen.availHeight);
|
|
29663
|
+
// 兼容旧版本callback
|
|
29664
|
+
if (typeof this.params.fullScreenCallBack === 'function') {
|
|
29665
|
+
this.params.fullScreenCallBack({ id: this.id, type: 'fullScreen', code: 0 });
|
|
29666
|
+
}
|
|
29364
29667
|
});
|
|
29365
29668
|
// 监听全屏事件触发
|
|
29366
29669
|
const fullscreenchange = () => {
|
|
@@ -29368,6 +29671,10 @@ class EZUIKitPlayer {
|
|
|
29368
29671
|
if (!isFullScreen) {
|
|
29369
29672
|
this.jSPlugin.JS_Resize(this.width, this.height);
|
|
29370
29673
|
}
|
|
29674
|
+
// 兼容旧版本callback
|
|
29675
|
+
if (typeof this.params.fullScreenChangeCallBack === 'function') {
|
|
29676
|
+
this.params.fullScreenChangeCallBack({ id: this.id, type: 'fullScreen', code: isFullScreen });
|
|
29677
|
+
}
|
|
29371
29678
|
};
|
|
29372
29679
|
['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange'].forEach((item) => {
|
|
29373
29680
|
window.addEventListener(item, (data) => fullscreenchange());
|
|
@@ -29386,6 +29693,19 @@ class EZUIKitPlayer {
|
|
|
29386
29693
|
stopTalk() {
|
|
29387
29694
|
this.Talk.startTalk();
|
|
29388
29695
|
}
|
|
29696
|
+
destroy() {
|
|
29697
|
+
var destroyRT = this.jSPlugin.JS_DestroyWorker(0);
|
|
29698
|
+
if (this.Theme) {
|
|
29699
|
+
this.Theme = null;
|
|
29700
|
+
window.EZUIKit[this.params.id].state.EZUIKitPlayer.themeInit = false;
|
|
29701
|
+
}
|
|
29702
|
+
if (isPromise(destroyRT)) {
|
|
29703
|
+
return destroyRT;
|
|
29704
|
+
}
|
|
29705
|
+
return new Promise(function (resolve) {
|
|
29706
|
+
resolve(destroyRT);
|
|
29707
|
+
});
|
|
29708
|
+
}
|
|
29389
29709
|
}
|
|
29390
29710
|
|
|
29391
29711
|
(function (global, factory) {
|