ezuikit-js 0.2.8 → 0.3.1-beta.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 CHANGED
@@ -90,6 +90,7 @@ import EZUIKit from 'ezuikit-js';
90
90
  |accessToken| String| 授权过程获取的access_token| Y|
91
91
  |url |String| 视频ezopen协议播放地址 |Y|
92
92
  |audio| int | 是否默认开启声音 1:打开(默认) 0:关闭 |N|
93
+ |autoplay| int | 是否自动播放 1:开启 0:关闭 |N|
93
94
  |width |int | 视频宽度,默认值为容器容器DOM宽度 |N|
94
95
  |height |int | 视频高度,默认值为容器容器DOM高度 |N|
95
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,16 +1443,16 @@
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
- _this.cancelFullScreen();
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)
@@ -1511,11 +1579,14 @@
1511
1579
  var containerDOM = document.getElementById(this.opt.id);
1512
1580
  containerDOM.style.width = width + 'px';
1513
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';
1514
1584
 
1515
1585
  var playDOM = document.getElementById(id);
1516
1586
  playDOM.setAttribute("width",width);
1517
1587
  playDOM.setAttribute("height",height);
1518
-
1588
+ playDOM.style.width = width + 'px';
1589
+ playDOM.style.height = height + 'px';
1519
1590
  setTimeout(function(){
1520
1591
  player.postMessage({
1521
1592
  action: 'autoResize',
@@ -1560,6 +1631,31 @@
1560
1631
  console.log("执行结束对讲");
1561
1632
  window.stopTalk();
1562
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
+ };
1563
1659
  /**
1564
1660
  * 视频播放器-结束
1565
1661
  */
@@ -10,7 +10,7 @@
10
10
  <div className="demo">
11
11
  <h2>视频模式使用示例:</h2>
12
12
  <div id="video-container"
13
- style="width:800px;"
13
+ style="width:600px;"
14
14
  >
15
15
  </div>
16
16
  <div>
@@ -32,32 +32,20 @@
32
32
  <script>
33
33
  var playr = new EZUIKit.EZUIKitPlayer({
34
34
  id: 'video-container', // 视频容器ID
35
- accessToken: 'at.1yjuprkk36992fts8qw4f0ladd9lju2y-1744sk6eh7-00cbr9r-ypsznozt8',
36
- url: 'ezopen://open.ys7.com/203751922/1.live',
37
- template: 'simple', // simple - 极简版;standard-标准版;security - 安防版(预览回放);voice-语音版;
35
+ accessToken: 'at.9or7li380hkqjr1c7rdke11abs1pa8sq-77ce7r93s1-1mjbwne-dmg4okcji',
36
+ url: 'ezopen://open.ys7.com/C78957921/1.live',
37
+ template: 'theme', // simple - 极简版;standard-标准版;security - 安防版(预览回放);voice-语音版; theme-可配置主题;
38
38
  autoplay: true,
39
- // 视频上方头部控件
40
- header: ['capturePicture','save','zoom'], // 如果templete参数不为simple,该字段将被覆盖
41
- // 视频下方底部控件
42
- footer: ['talk','broadcast','hd','fullScreen'], // 如果template参数不为simple,该字段将被覆盖
43
39
  // audio: 1, // 是否默认开启声音 0 - 关闭 1 - 开启
44
- // plugin: ['talk'], // 加载插件,talk-对讲
40
+ plugin: ['talk'], // 加载插件,talk-对讲
45
41
  // controls: true, //['play','voice','hd','fullScreen'], // 视频控制相关控件,如果template参数不为simple,该字段将被覆盖
46
- openSoundCallBack: (data) => console.log("开启声音回调",data),
47
- closeSoundCallBack: (data) => console.log("关闭声音回调",data),
48
- startSaveCallBack: (data) => console.log("开始录像回调",data),
49
- stopSaveCallBack: (data) => console.log("录像回调",data),
50
- capturePictureCallBack: (data) => console.log("截图成功回调",data),
51
- fullScreenCallBack: (data) => console.log("全屏回调",data),
52
- fullScreenChangeCallBack: (data) => console.log("全屏变化回调",data),
53
- getOSDTimeCallBack: (data) => console.log("获取OSDTime回调",data),
54
42
  handleSuccess: (data) = function(){console.log("播放成功回调",data)},
55
43
  handleError: (data) => console.log("播放失败回调1",data),
56
- handleTalkSuccess: () => console.log("对讲成功回掉"),
44
+ handleTalkSuccess: () => console.log("对讲成功回调"),
57
45
  handleTalkError: (data) = function(){console.log("对讲失败",data)},
58
46
  decoderVersion: "v3.4",
59
- width:800,
60
- height:600,
47
+ width: 600,
48
+ height:400,
61
49
  });
62
50
  function fullScreen(){
63
51
  var playPromise = playr.fullScreen();