ezuikit-js 0.2.6 → 0.3.0
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/README.md +26 -2
- package/demos/base-demo/ezuikit.js +112 -19
- package/demos/base-demo/index.html +17 -22
- package/demos/base-demo-debug/ezuikit.js +1584 -0
- package/demos/base-demo-debug/index.html +124 -0
- package/demos/base-demo-debug/multi-demo.html +213 -0
- package/ezuikit.js +112 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,18 +46,41 @@ import EZUIKit from 'ezuikit-js';
|
|
|
46
46
|
> 示例: 停止播放
|
|
47
47
|
|
|
48
48
|
```
|
|
49
|
-
player.stop();
|
|
49
|
+
1. player.stop();
|
|
50
|
+
|
|
51
|
+
2. player.stop()
|
|
52
|
+
.then(()=>{
|
|
53
|
+
console.log("执行播放成功后其他动作");
|
|
54
|
+
});
|
|
55
|
+
|
|
50
56
|
```
|
|
51
57
|
> 示例: 执行播放(自动播放为false,自定义触发播放/切换播放地址)
|
|
52
58
|
|
|
53
59
|
```
|
|
54
60
|
player.play();
|
|
55
|
-
//
|
|
61
|
+
// 切换播放地址场景(注意先执行stop方法停止上次取流)
|
|
56
62
|
player.play({
|
|
57
63
|
url: 'ezopen://open.ys7.com/203751922/1.rec?begin=202001000000&end=202001235959'
|
|
58
64
|
});
|
|
59
65
|
```
|
|
60
66
|
|
|
67
|
+
切换地址播放(注意需要先执行stop方法停止上次取流)
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
player.stop()
|
|
71
|
+
.then(()=>{
|
|
72
|
+
player.play('ezopen://open.ys7.com/{其他设备}/{其他通道}.live');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// 其他账号下设备
|
|
76
|
+
|
|
77
|
+
player.stop()
|
|
78
|
+
.then(()=>{
|
|
79
|
+
player.play({url:'ezopen://open.ys7.com/{其他设备}/{其他通道}.live',accessToken: 'xxxx'});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
|
|
61
84
|
### 使用说明
|
|
62
85
|
#### 初始化
|
|
63
86
|
|
|
@@ -67,6 +90,7 @@ import EZUIKit from 'ezuikit-js';
|
|
|
67
90
|
|accessToken| String| 授权过程获取的access_token| Y|
|
|
68
91
|
|url |String| 视频ezopen协议播放地址 |Y|
|
|
69
92
|
|audio| int | 是否默认开启声音 1:打开(默认) 0:关闭 |N|
|
|
93
|
+
|autoplay| int | 是否自动播放 1:开启 0:关闭 |N|
|
|
70
94
|
|width |int | 视频宽度,默认值为容器容器DOM宽度 |N|
|
|
71
95
|
|height |int | 视频高度,默认值为容器容器DOM高度 |N|
|
|
72
96
|
|templete |string | 播放器模板,可以通过选定模板,使用内置的播放器样式,组件 simple:极简版;standard:标准版;security:安防版(预览回放);vioce:语音版 |N|
|
|
@@ -86,6 +86,17 @@
|
|
|
86
86
|
|
|
87
87
|
http_request.send(data);
|
|
88
88
|
}
|
|
89
|
+
var requestFullScreen = function (element) {
|
|
90
|
+
var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
|
|
91
|
+
if (requestMethod) {
|
|
92
|
+
requestMethod.call(element);
|
|
93
|
+
} else if (typeof window.ActiveXObject !== "undefined") {
|
|
94
|
+
var wscript = new ActiveXObject("WScript.Shell");
|
|
95
|
+
if (wscript !== null) {
|
|
96
|
+
wscript.SendKeys("{F11}");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
89
100
|
|
|
90
101
|
; // 全局属性
|
|
91
102
|
|
|
@@ -191,6 +202,9 @@
|
|
|
191
202
|
this.opt.filePathDomain = params.env.filePathDomain;
|
|
192
203
|
}
|
|
193
204
|
}
|
|
205
|
+
// if(typeof params.domain !== 'undefined'){
|
|
206
|
+
// this.opt.apiDomain = params.domain + '/api/lapp/live/talk/url';
|
|
207
|
+
// }
|
|
194
208
|
|
|
195
209
|
if (params.url) {
|
|
196
210
|
this.opt.url = params.url;
|
|
@@ -257,6 +271,30 @@
|
|
|
257
271
|
case 'security':
|
|
258
272
|
return domain + "/ezopen/h5/iframe_se?bSupporDoubleClickFull=0&url=" + _this.opt.url.replace("?","&") + "&autoplay=" + _this.opt.autoplay + "&audio=" + _this.opt.audio + "&accessToken=" + params.accessToken + "&templete=0" + "&id=" + id + "&decoderVersion=" + _this.opt.decoderVersion;
|
|
259
273
|
|
|
274
|
+
case 'theme':
|
|
275
|
+
iframeUrl = domain +`/jssdk/theme.html?url=${params.url}&accessToken=${params.accessToken}&id=${id}&isMobile=${params.isMobile}`;
|
|
276
|
+
if(typeof params.isMobile !== 'undefined') {
|
|
277
|
+
iframeUrl += '&isMobile=' + params.isMobile;
|
|
278
|
+
}
|
|
279
|
+
if(typeof params.autoplay !== 'undefined') {
|
|
280
|
+
iframeUrl += '&autoplay=' + params.autoplay;
|
|
281
|
+
}
|
|
282
|
+
if(typeof params.domain !== 'undefined') {
|
|
283
|
+
if(params.domain == 'https://test12open.ys7.com')
|
|
284
|
+
iframeUrl += '&env=' + 'test12';
|
|
285
|
+
}
|
|
286
|
+
if (typeof params.env !== 'undefined') {
|
|
287
|
+
if(typeof params.env.domain !== 'undefined'){
|
|
288
|
+
if(params.env.domain == 'https://test12open.ys7.com'){
|
|
289
|
+
iframeUrl += '&env=' + 'test12';
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if(typeof params.header !== 'undefined') {
|
|
294
|
+
iframeUrl += '&header=' + params.header;
|
|
295
|
+
}
|
|
296
|
+
return iframeUrl;
|
|
297
|
+
|
|
260
298
|
default:
|
|
261
299
|
return domain + "/ezopen/h5/iframe?bSupporDoubleClickFull=0&url=" + _this.opt.url.replace("?","&") + "&autoplay=" + _this.opt.autoplay + "&audio=" + _this.opt.audio + "&accessToken=" + params.accessToken + "&templete=0" + "&id=" + id + "&decoderVersion=" + _this.opt.decoderVersion;
|
|
262
300
|
}
|
|
@@ -269,10 +307,16 @@
|
|
|
269
307
|
|
|
270
308
|
if (params.height) {
|
|
271
309
|
iframeHeight = parseInt(params.height);
|
|
310
|
+
if(/\%$/.test(params.height)) {
|
|
311
|
+
iframeWidth = document.getElementById(id).offsetWidth * (parseInt(params.height) /100);
|
|
312
|
+
}
|
|
272
313
|
}
|
|
273
314
|
|
|
274
315
|
if (params.width) {
|
|
275
316
|
iframeWidth = parseInt(params.width);
|
|
317
|
+
if(/\%$/.test(params.width)) {
|
|
318
|
+
iframeWidth = document.getElementById(id).offsetWidth * (parseInt(params.width) /100);
|
|
319
|
+
}
|
|
276
320
|
}
|
|
277
321
|
|
|
278
322
|
iframe.width = iframeWidth;
|
|
@@ -546,7 +590,6 @@
|
|
|
546
590
|
params.handleError(err);
|
|
547
591
|
}
|
|
548
592
|
}
|
|
549
|
-
|
|
550
593
|
request(_this.opt.apiDomain, 'POST', {
|
|
551
594
|
accessToken: _this.opt.accessToken,
|
|
552
595
|
deviceSerial: _this.opt.deviceSerial,
|
|
@@ -1131,7 +1174,6 @@
|
|
|
1131
1174
|
|
|
1132
1175
|
var _this = this;
|
|
1133
1176
|
window.addEventListener("message", function (event) {
|
|
1134
|
-
console.log("EZUIKitPlayer收到反馈", event);
|
|
1135
1177
|
var origin = event.origin;
|
|
1136
1178
|
var id = _this.opt.id;
|
|
1137
1179
|
if (event.data.type) {
|
|
@@ -1204,6 +1246,32 @@
|
|
|
1204
1246
|
}
|
|
1205
1247
|
}
|
|
1206
1248
|
break;
|
|
1249
|
+
case 'startTalk':
|
|
1250
|
+
_this.startTalk();
|
|
1251
|
+
// params.startTalk();
|
|
1252
|
+
_this.closeSound();
|
|
1253
|
+
break;
|
|
1254
|
+
case 'stopTalk':
|
|
1255
|
+
// window.stopTalk()
|
|
1256
|
+
// params.stopTalk();
|
|
1257
|
+
_this.openSound();
|
|
1258
|
+
break;
|
|
1259
|
+
case 'clickEventHandle':
|
|
1260
|
+
console.log("event.data",event.data);
|
|
1261
|
+
if(params.clickEventHandle) {
|
|
1262
|
+
params.clickEventHandle(event.data);
|
|
1263
|
+
}
|
|
1264
|
+
break;
|
|
1265
|
+
case 'removeEventHandle':
|
|
1266
|
+
if(params.removeEventHandle) {
|
|
1267
|
+
params.removeEventHandle(event.data);
|
|
1268
|
+
}
|
|
1269
|
+
break;
|
|
1270
|
+
case 'esc':
|
|
1271
|
+
if(params.clickEventHandle) {
|
|
1272
|
+
params.clickEventHandle(event.data);
|
|
1273
|
+
}
|
|
1274
|
+
break;
|
|
1207
1275
|
}
|
|
1208
1276
|
}
|
|
1209
1277
|
});
|
|
@@ -1375,19 +1443,19 @@
|
|
|
1375
1443
|
style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
|
|
1376
1444
|
style += 'position: fixed;top: 0;left: 0;z-index:10';
|
|
1377
1445
|
wrapper.style.cssText = style;
|
|
1378
|
-
var cancelFullDOM = document.createElement('div');
|
|
1379
|
-
cancelFullDOM.id = id + "cancel-full-screen"
|
|
1380
|
-
var cancelFullDOMStyle="width:30px;height:"+height+"px;z-index:1000;position:fixed;top:0px;right:0px;";
|
|
1381
|
-
cancelFullDOMStyle += "background-image: url(https://resource.ys7cloud.com/group1/M00/00/7E/CtwQE1-01qeAH2wAAAABOliqQ5g167.png);"
|
|
1382
|
-
cancelFullDOMStyle += "background-size: contain;background-repeat:no-repeat;background-color:rgba(0,0,0,0.2)"
|
|
1383
|
-
cancelFullDOM.style = cancelFullDOMStyle;
|
|
1384
|
-
cancelFullDOM.onclick = function(){
|
|
1385
|
-
|
|
1386
|
-
}
|
|
1387
|
-
document.body.appendChild(cancelFullDOM);
|
|
1446
|
+
// var cancelFullDOM = document.createElement('div');
|
|
1447
|
+
// cancelFullDOM.id = id + "cancel-full-screen"
|
|
1448
|
+
// var cancelFullDOMStyle="width:30px;height:"+height+"px;z-index:1000;position:fixed;top:0px;right:0px;";
|
|
1449
|
+
// cancelFullDOMStyle += "background-image: url(https://resource.ys7cloud.com/group1/M00/00/7E/CtwQE1-01qeAH2wAAAABOliqQ5g167.png);"
|
|
1450
|
+
// cancelFullDOMStyle += "background-size: contain;background-repeat:no-repeat;background-color:rgba(0,0,0,0.2)"
|
|
1451
|
+
// cancelFullDOM.style = cancelFullDOMStyle;
|
|
1452
|
+
// cancelFullDOM.onclick = function(){
|
|
1453
|
+
// _this.cancelFullScreen();
|
|
1454
|
+
// }
|
|
1455
|
+
// document.body.appendChild(cancelFullDOM);
|
|
1388
1456
|
setTimeout(function () {
|
|
1389
1457
|
player.postMessage('autoResize', domain + "/ezopen/h5/iframe")
|
|
1390
|
-
},
|
|
1458
|
+
}, 500)
|
|
1391
1459
|
|
|
1392
1460
|
} else {
|
|
1393
1461
|
// console.log('pc端全屏');
|
|
@@ -1403,9 +1471,6 @@
|
|
|
1403
1471
|
}
|
|
1404
1472
|
}
|
|
1405
1473
|
requestFullScreen(document.getElementById(id));
|
|
1406
|
-
setTimeout(function () {
|
|
1407
|
-
player.postMessage("autoResize", domain + "/ezopen/h5/iframe")
|
|
1408
|
-
}, 200)
|
|
1409
1474
|
}
|
|
1410
1475
|
if (this.params.fullScreenCallBack) {
|
|
1411
1476
|
this.params.fullScreenCallBack(this.opt.id);
|
|
@@ -1433,7 +1498,7 @@
|
|
|
1433
1498
|
wrapper.style.cssText = style;
|
|
1434
1499
|
setTimeout(function () {
|
|
1435
1500
|
player.postMessage("autoResize", domain + "/ezopen/h5/iframe")
|
|
1436
|
-
},
|
|
1501
|
+
}, 500);
|
|
1437
1502
|
var cancelFullDOMId = id + "cancel-full-screen";
|
|
1438
1503
|
var cancelFullDOM = document.getElementById(cancelFullDOMId);
|
|
1439
1504
|
if(cancelFullDOM){
|
|
@@ -1514,16 +1579,19 @@
|
|
|
1514
1579
|
var containerDOM = document.getElementById(this.opt.id);
|
|
1515
1580
|
containerDOM.style.width = width + 'px';
|
|
1516
1581
|
containerDOM.style.height = height + 'px';
|
|
1582
|
+
document.getElementById(this.opt.id).style.width = width + 'px';
|
|
1583
|
+
document.getElementById(this.opt.id).style.height = height + 'px';
|
|
1517
1584
|
|
|
1518
1585
|
var playDOM = document.getElementById(id);
|
|
1519
1586
|
playDOM.setAttribute("width",width);
|
|
1520
1587
|
playDOM.setAttribute("height",height);
|
|
1521
|
-
|
|
1588
|
+
playDOM.style.width = width + 'px';
|
|
1589
|
+
playDOM.style.height = height + 'px';
|
|
1522
1590
|
setTimeout(function(){
|
|
1523
1591
|
player.postMessage({
|
|
1524
1592
|
action: 'autoResize',
|
|
1525
1593
|
}, domain + "/ezopen/h5/iframe");
|
|
1526
|
-
},
|
|
1594
|
+
},500)
|
|
1527
1595
|
};
|
|
1528
1596
|
|
|
1529
1597
|
EZUIKitPlayer.prototype.startTalk = function () {
|
|
@@ -1563,6 +1631,31 @@
|
|
|
1563
1631
|
console.log("执行结束对讲");
|
|
1564
1632
|
window.stopTalk();
|
|
1565
1633
|
};
|
|
1634
|
+
EZUIKitPlayer.prototype.edit = function () {
|
|
1635
|
+
var id = 'EZUIKitPlayer-' + this.opt.id;
|
|
1636
|
+
var player = document.getElementById(id).contentWindow;
|
|
1637
|
+
player.postMessage("edit", domain + "/ezopen/h5/iframe");
|
|
1638
|
+
};
|
|
1639
|
+
EZUIKitPlayer.prototype.btnReRender = function (data) {
|
|
1640
|
+
var id = 'EZUIKitPlayer-' + this.opt.id;
|
|
1641
|
+
var player = document.getElementById(id).contentWindow;
|
|
1642
|
+
player.postMessage({action: "btnReRender",data: data}, domain + "/ezopen/h5/iframe")
|
|
1643
|
+
};
|
|
1644
|
+
EZUIKitPlayer.prototype.changePlayUrl = function (data) {
|
|
1645
|
+
var id = 'EZUIKitPlayer-' + this.opt.id;
|
|
1646
|
+
var player = document.getElementById(id).contentWindow;
|
|
1647
|
+
player.postMessage({action: "changePlayUrl",data: data}, domain + "/ezopen/h5/iframe");
|
|
1648
|
+
};
|
|
1649
|
+
EZUIKitPlayer.prototype.fetchThemeData = function () {
|
|
1650
|
+
var id = 'EZUIKitPlayer-' + this.opt.id;
|
|
1651
|
+
var player = document.getElementById(id).contentWindow;
|
|
1652
|
+
player.postMessage({action: "fetchThemeData"}, domain + "/ezopen/h5/iframe")
|
|
1653
|
+
};
|
|
1654
|
+
EZUIKitPlayer.prototype.setThemeData = function (accessToken, header, footer) {
|
|
1655
|
+
var id = 'EZUIKitPlayer-' + this.opt.id;
|
|
1656
|
+
var player = document.getElementById(id).contentWindow;
|
|
1657
|
+
player.postMessage({action: "setThemeData",data:{accessToken, header, footer}}, domain + "/ezopen/h5/iframe")
|
|
1658
|
+
};
|
|
1566
1659
|
/**
|
|
1567
1660
|
* 视频播放器-结束
|
|
1568
1661
|
*/
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<div className="demo">
|
|
11
11
|
<h2>视频模式使用示例:</h2>
|
|
12
12
|
<div id="video-container"
|
|
13
|
-
style="width:
|
|
13
|
+
style="width:600px;"
|
|
14
14
|
>
|
|
15
15
|
</div>
|
|
16
16
|
<div>
|
|
@@ -25,39 +25,34 @@
|
|
|
25
25
|
<button onClick="stopSave()">stopSave</button>
|
|
26
26
|
<button onClick="startTalk()">开始对讲</button>
|
|
27
27
|
<button onClick="stopTalk()">结束对讲</button>
|
|
28
|
+
<button onClick="fullScreen()">全屏</button>
|
|
28
29
|
</div>
|
|
29
30
|
<p style="font-style: italic;">播放多个视频,可初始化多个实例,参考:/demos/base-demo/multi-demo</p>
|
|
30
31
|
</div>
|
|
31
32
|
<script>
|
|
32
33
|
var playr = new EZUIKit.EZUIKitPlayer({
|
|
33
34
|
id: 'video-container', // 视频容器ID
|
|
34
|
-
accessToken: 'at.
|
|
35
|
-
url: 'ezopen://open.ys7.com/
|
|
36
|
-
template: '
|
|
35
|
+
accessToken: 'at.9or7li380hkqjr1c7rdke11abs1pa8sq-77ce7r93s1-1mjbwne-dmg4okcji',
|
|
36
|
+
url: 'ezopen://open.ys7.com/C78957921/1.live',
|
|
37
|
+
template: 'theme', // simple - 极简版;standard-标准版;security - 安防版(预览回放);voice-语音版; theme-可配置主题;
|
|
37
38
|
autoplay: true,
|
|
38
|
-
// 视频上方头部控件
|
|
39
|
-
header: ['capturePicture','save','zoom'], // 如果templete参数不为simple,该字段将被覆盖
|
|
40
|
-
// 视频下方底部控件
|
|
41
|
-
footer: ['talk','broadcast','hd','fullScreen'], // 如果template参数不为simple,该字段将被覆盖
|
|
42
39
|
// audio: 1, // 是否默认开启声音 0 - 关闭 1 - 开启
|
|
43
|
-
|
|
40
|
+
plugin: ['talk'], // 加载插件,talk-对讲
|
|
44
41
|
// controls: true, //['play','voice','hd','fullScreen'], // 视频控制相关控件,如果template参数不为simple,该字段将被覆盖
|
|
45
|
-
openSoundCallBack: (data) => console.log("开启声音回调",data),
|
|
46
|
-
closeSoundCallBack: (data) => console.log("关闭声音回调",data),
|
|
47
|
-
startSaveCallBack: (data) => console.log("开始录像回调",data),
|
|
48
|
-
stopSaveCallBack: (data) => console.log("录像回调",data),
|
|
49
|
-
capturePictureCallBack: (data) => console.log("截图成功回调",data),
|
|
50
|
-
fullScreenCallBack: (data) => console.log("全屏回调",data),
|
|
51
|
-
fullScreenChangeCallBack: (data) => console.log("全屏变化回调",data),
|
|
52
|
-
getOSDTimeCallBack: (data) => console.log("获取OSDTime回调",data),
|
|
53
42
|
handleSuccess: (data) = function(){console.log("播放成功回调",data)},
|
|
54
|
-
handleError: (data) => console.log("播放失败回调",data),
|
|
55
|
-
handleTalkSuccess: () => console.log("
|
|
43
|
+
handleError: (data) => console.log("播放失败回调1",data),
|
|
44
|
+
handleTalkSuccess: () => console.log("对讲成功回调"),
|
|
56
45
|
handleTalkError: (data) = function(){console.log("对讲失败",data)},
|
|
57
|
-
decoderVersion: "
|
|
58
|
-
width:
|
|
46
|
+
decoderVersion: "v3.4",
|
|
47
|
+
width: 600,
|
|
59
48
|
height:400,
|
|
60
49
|
});
|
|
50
|
+
function fullScreen(){
|
|
51
|
+
var playPromise = playr.fullScreen();
|
|
52
|
+
playPromise.then((data)=>{
|
|
53
|
+
console.log("promise 获取 数据",data)
|
|
54
|
+
})
|
|
55
|
+
}
|
|
61
56
|
function play() {
|
|
62
57
|
var playPromise = playr.play();
|
|
63
58
|
playPromise.then((data)=>{
|
|
@@ -114,4 +109,4 @@
|
|
|
114
109
|
}
|
|
115
110
|
</script>
|
|
116
111
|
</body>
|
|
117
|
-
</html>
|
|
112
|
+
</html>
|