ezuikit-js 0.2.9 → 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 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;
@@ -233,7 +247,6 @@
233
247
  */
234
248
 
235
249
  var iframe = document.createElement('iframe');
236
- domain = 'http://y.ys7.com:3100'
237
250
 
238
251
  function matchIframeUrl() {
239
252
  switch (_this.opt.template) {
@@ -258,6 +271,30 @@
258
271
  case 'security':
259
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;
260
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
+
261
298
  default:
262
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;
263
300
  }
@@ -553,7 +590,6 @@
553
590
  params.handleError(err);
554
591
  }
555
592
  }
556
-
557
593
  request(_this.opt.apiDomain, 'POST', {
558
594
  accessToken: _this.opt.accessToken,
559
595
  deviceSerial: _this.opt.deviceSerial,
@@ -1138,7 +1174,6 @@
1138
1174
 
1139
1175
  var _this = this;
1140
1176
  window.addEventListener("message", function (event) {
1141
- console.log("EZUIKitPlayer收到反馈", event);
1142
1177
  var origin = event.origin;
1143
1178
  var id = _this.opt.id;
1144
1179
  if (event.data.type) {
@@ -1211,6 +1246,32 @@
1211
1246
  }
1212
1247
  }
1213
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;
1214
1275
  }
1215
1276
  }
1216
1277
  });
@@ -1382,16 +1443,16 @@
1382
1443
  style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
1383
1444
  style += 'position: fixed;top: 0;left: 0;z-index:10';
1384
1445
  wrapper.style.cssText = style;
1385
- var cancelFullDOM = document.createElement('div');
1386
- cancelFullDOM.id = id + "cancel-full-screen"
1387
- var cancelFullDOMStyle="width:30px;height:"+height+"px;z-index:1000;position:fixed;top:0px;right:0px;";
1388
- cancelFullDOMStyle += "background-image: url(https://resource.ys7cloud.com/group1/M00/00/7E/CtwQE1-01qeAH2wAAAABOliqQ5g167.png);"
1389
- cancelFullDOMStyle += "background-size: contain;background-repeat:no-repeat;background-color:rgba(0,0,0,0.2)"
1390
- cancelFullDOM.style = cancelFullDOMStyle;
1391
- cancelFullDOM.onclick = function(){
1392
- _this.cancelFullScreen();
1393
- }
1394
- 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);
1395
1456
  setTimeout(function () {
1396
1457
  player.postMessage('autoResize', domain + "/ezopen/h5/iframe")
1397
1458
  }, 500)
@@ -1518,11 +1579,14 @@
1518
1579
  var containerDOM = document.getElementById(this.opt.id);
1519
1580
  containerDOM.style.width = width + 'px';
1520
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';
1521
1584
 
1522
1585
  var playDOM = document.getElementById(id);
1523
1586
  playDOM.setAttribute("width",width);
1524
1587
  playDOM.setAttribute("height",height);
1525
-
1588
+ playDOM.style.width = width + 'px';
1589
+ playDOM.style.height = height + 'px';
1526
1590
  setTimeout(function(){
1527
1591
  player.postMessage({
1528
1592
  action: 'autoResize',
@@ -1567,6 +1631,31 @@
1567
1631
  console.log("执行结束对讲");
1568
1632
  window.stopTalk();
1569
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
+ };
1570
1659
  /**
1571
1660
  * 视频播放器-结束
1572
1661
  */
@@ -10,6 +10,7 @@
10
10
  <div className="demo">
11
11
  <h2>视频模式使用示例:</h2>
12
12
  <div id="video-container"
13
+ style="width:600px;"
13
14
  >
14
15
  </div>
15
16
  <div>
@@ -29,35 +30,22 @@
29
30
  <p style="font-style: italic;">播放多个视频,可初始化多个实例,参考:/demos/base-demo/multi-demo</p>
30
31
  </div>
31
32
  <script>
32
- document.getElementById("video-container").innerHTML="";
33
33
  var playr = new EZUIKit.EZUIKitPlayer({
34
34
  id: 'video-container', // 视频容器ID
35
- accessToken: 'at.24gy1xhw62tw1ciod2rkbcn2cbs0esju-2h73bhdmbw-0lzya5g-yev2hyd5z',
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
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
44
  handleTalkSuccess: () => console.log("对讲成功回调"),
57
45
  handleTalkError: (data) = function(){console.log("对讲失败",data)},
58
46
  decoderVersion: "v3.4",
59
- width:"100%",
60
- height:219,
47
+ width: 600,
48
+ height:400,
61
49
  });
62
50
  function fullScreen(){
63
51
  var playPromise = playr.fullScreen();