ezuikit-js 0.4.3 → 0.4.6

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.
Files changed (2) hide show
  1. package/ezuikit.js +194 -78
  2. package/package.json +1 -1
package/ezuikit.js CHANGED
@@ -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://cdn.jsdelivr.net/npm/hls.js@latest", () => {
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()) {
@@ -24067,7 +24067,8 @@ C11.4,16.3,11,16.6,10.6,16.6z" />
24067
24067
  }
24068
24068
  this.timer = setInterval(() => {
24069
24069
  var getOSDTimePromise = this.jSPlugin.getOSDTime();
24070
- getOSDTimePromise.then((v) => {
24070
+ getOSDTimePromise.then((data) => {
24071
+ var v = data.data;
24071
24072
  if (v === -1) {
24072
24073
  console.log("获取播放时间错误");
24073
24074
  } else {
@@ -26106,12 +26107,19 @@ class Theme {
26106
26107
  this.initThemeData();
26107
26108
  this.renderThemeData();
26108
26109
  break;
26110
+ case 'themeData':
26111
+ this.themeData = this.jSPlugin.params.themeData;
26112
+ this.initThemeData();
26113
+ this.renderThemeData();
26109
26114
  default:
26110
26115
  this.fetchThemeData(this.jSPlugin.themeId);
26111
26116
  break;
26112
26117
  }
26113
26118
  }
26114
- if ((this.decoderState.state.cloudRec) || (this.decoderState.state.rec)) {
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) {
26115
26123
  if (this.isMobile) {
26116
26124
  this.Rec = new MobileRec(jSPlugin);
26117
26125
  } else {
@@ -26121,7 +26129,7 @@ class Theme {
26121
26129
  if (!this.jSPlugin.Talk) {
26122
26130
  this.jSPlugin.Talk = new Talk(this.jSPlugin);
26123
26131
  }
26124
- if (this.decoderState.state.type === 'live') {
26132
+ if (matchEzopenUrl(jSPlugin.url).type === 'live') {
26125
26133
  if (this.isMobile) {
26126
26134
  this.MobilePtz = new MobilePtz(jSPlugin);
26127
26135
  this.Ptz = new Ptz(jSPlugin);
@@ -26212,7 +26220,7 @@ class Theme {
26212
26220
  }
26213
26221
  break;
26214
26222
  case 'sound':
26215
- if (`${this.jSPlugin.id}-sound`) {
26223
+ if (document.getElementById(`${this.jSPlugin.id}-sound`)) {
26216
26224
  if (options[item]) {
26217
26225
  document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[1].style = "display:inline-block";
26218
26226
  document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[0].style = "display:none";
@@ -27002,6 +27010,43 @@ class Theme {
27002
27010
  }
27003
27011
  }
27004
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
+
27005
27050
  /**
27006
27051
  * EZUIKitPlayer for npm
27007
27052
  */
@@ -28601,9 +28646,15 @@ var EZUIKitV3$1 = EZUIKitV3;
28601
28646
 
28602
28647
  // iframe模板 - 兼容旧版本
28603
28648
  const matchTemplate = (templateName, params) => {
28604
- const IFRAMETEMPLATE = ['simple', 'standard', 'security', 'vioce', 'theme'];
28605
- const LOCALTEMPLATE = ['pcLive', 'pcRec', 'mobileLive', 'mobileRec', 'noData'];
28649
+ const IFRAMETEMPLATE = ['simple', 'standard', 'security', 'voice', 'theme'];
28650
+ const LOCALTEMPLATE = ['pcLive', 'pcRec', 'mobileLive', 'mobileRec', 'noData', ''];
28606
28651
  if (typeof templateName === 'undefined') {
28652
+ if(params.themeData) {
28653
+ return {
28654
+ templateType: 'themeData',
28655
+ templateId: 'themeData'
28656
+ }
28657
+ }
28607
28658
  return {
28608
28659
  templateType: 'local',
28609
28660
  templateId: ''
@@ -28650,6 +28701,9 @@ class EZUIKitPlayer {
28650
28701
  }
28651
28702
  };
28652
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
+ });
28653
28707
  this.id = params.id;
28654
28708
  this.width = params.width;
28655
28709
  this.height = params.height;
@@ -28657,25 +28711,50 @@ class EZUIKitPlayer {
28657
28711
  this.accessToken = params.accessToken;
28658
28712
  this.themeId = matchTemplate(params.template, params).templateId;
28659
28713
  this.id = params.id;
28660
- this.audio = params.audio;
28714
+ this.audio = true;
28661
28715
  this.poster = params.poster;
28662
28716
  this.speed = 1;
28663
28717
  this.staticPath = "https://open.ys7.com/assets/ezuikit_v4.0";
28664
28718
  if (typeof params.staticPath === 'string') {
28665
28719
  this.staticPath = params.staticPath;
28666
28720
  }
28721
+ if(typeof params.audio !== 'undefined') {
28722
+ this.audio = params.audio;
28723
+ }
28667
28724
  addJs(`${this.staticPath}/js/AudioRenderer.js`, () => {
28668
28725
  addJs(`${this.staticPath}/js/SuperRender_10.js`, () => {
28669
28726
  addJs(`${this.staticPath}/js/jsPlugin-4.0.2.min.js`, () => {
28670
28727
  if (autoplay) {
28728
+ this.initTime = new Date().getTime();
28729
+ this.Monitor.dclog({
28730
+ url: this.url,
28731
+ action: 0,
28732
+ text: 'startInit',
28733
+ });
28671
28734
  var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
28672
28735
  var getRealUrlPromise = this._getRealUrlPromise(params.accessToken, params.url);
28673
28736
  Promise.all([initEZUIKitPlayerPromise, getRealUrlPromise]).then(values => {
28674
28737
  console.log("values", values);
28675
28738
  if (values[1]) {
28676
28739
  this._pluginPlay(values[1],
28677
- () => { console.log("自动播放成功"); },
28678
- () => { console.log("自动播放失败"); },
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
+ },
28679
28758
  );
28680
28759
  }
28681
28760
  window.EZUIKit[params.id].state.EZUIKitPlayer.init = true;
@@ -28684,6 +28763,12 @@ class EZUIKitPlayer {
28684
28763
  }
28685
28764
  });
28686
28765
  } else {
28766
+ this.initTime = new Date().getTime();
28767
+ this.Monitor.dclog({
28768
+ url: this.url,
28769
+ action: 0,
28770
+ text: 'startInit',
28771
+ });
28687
28772
  var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
28688
28773
  initEZUIKitPlayerPromise.then((data) => {
28689
28774
  console.log("初始化成功", data);
@@ -28691,6 +28776,12 @@ class EZUIKitPlayer {
28691
28776
  if (document.getElementById(`${params.id}canvas_draw0`)) {
28692
28777
  document.getElementById(`${params.id}canvas_draw0`).style.border = "none";
28693
28778
  }
28779
+ this.Monitor.dclog({
28780
+ url: this.url,
28781
+ action: 201,
28782
+ d: new Date().getTime() - this.initTime,
28783
+ text: 'initSuccess',
28784
+ });
28694
28785
  });
28695
28786
  }
28696
28787
  });
@@ -28763,8 +28854,10 @@ class EZUIKitPlayer {
28763
28854
  },
28764
28855
  windowFullCcreenChange: function (bFull) {
28765
28856
  },
28766
- firstFrameDisplay: function (iWndIndex, iWidth, iHeight) {
28857
+ firstFrameDisplay: (iWndIndex, iWidth, iHeight) => {
28858
+ console.log(iWidth, iHeight);
28767
28859
  jSPlugin.JS_SetCanFullScreen(false);
28860
+ this.pluginStatus.loadingClear();
28768
28861
  },
28769
28862
  performanceLack: function () {
28770
28863
  },
@@ -29121,7 +29214,6 @@ class EZUIKitPlayer {
29121
29214
 
29122
29215
  this.jSPlugin.JS_Play(wsUrl, wsParams, 0).then(() => {
29123
29216
  console.log("播放成功");
29124
- this.pluginStatus.loadingClear();
29125
29217
  if (this.Theme) {
29126
29218
  this.Theme.setDecoderState({ play: true });
29127
29219
  }
@@ -29138,6 +29230,12 @@ class EZUIKitPlayer {
29138
29230
  });
29139
29231
  }
29140
29232
  successCallback();
29233
+ this.Monitor.dclog({
29234
+ url: this.url,
29235
+ action: 211,
29236
+ d: new Date().getTime() - this.playStartTime,
29237
+ text: 'startPlaySuccess'
29238
+ });
29141
29239
  }, (err) => {
29142
29240
  var errorInfo = this.errorHander.matchErrorInfo(err.oError.errorCode);
29143
29241
  var msg = errorInfo ? errorInfo.description : '播放失败,请检查设备及客户端网络';
@@ -29153,80 +29251,38 @@ class EZUIKitPlayer {
29153
29251
  type: "handleError"
29154
29252
  });
29155
29253
  }
29156
- successCallback(errorCallback);
29254
+ errorCallback();
29255
+ this.Monitor.dclog({
29256
+ url: this.url,
29257
+ action: 411,
29258
+ d: new Date().getTime() - this.playStartTime,
29259
+ text: 'startPlayError'
29260
+ });
29157
29261
  });
29158
29262
  }
29159
29263
  play(options) {
29160
- if(typeof options.url === 'string') {
29161
- this.url = options.url;
29162
- }
29163
- if(typeof options.accessToken === 'string') {
29164
- this.accessToken = options.accessToken;
29165
- }
29166
- if(this.Theme && (typeof options.url === 'string' || typeof options.accessToken === 'string')) {
29167
- this.Theme.getDeviceInfo();
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
+ }
29168
29281
  }
29169
29282
  const promise = new Promise((resolve, reject) => {
29170
29283
  this._getRealUrlPromise(this.accessToken, this.url)
29171
29284
  .then((data) => {
29172
29285
  this._pluginPlay(data, () => resolve(true), () => reject(false));
29173
- // console.log("get real url result ===", data);
29174
- // function getPlayParams(url) {
29175
- // var websocketConnectUrl = url.split('?')[0].replace('/live', '').replace('/playback', '');
29176
- // var websocketStreamingParam = (url.indexOf('/live') === -1 ? (url.indexOf('cloudplayback') !== -1 ? '/cloudplayback?' : '/playback?') : '/live?') + url.split('?')[1];
29177
- // if (websocketStreamingParam.indexOf('/playback') !== -1) {
29178
- // websocketStreamingParam = websocketStreamingParam.replace("stream=2", 'stream=1');
29179
- // }
29180
- // // 本地回放仅支持主码流
29181
- // return {
29182
- // websocketConnectUrl: websocketConnectUrl,
29183
- // websocketStreamingParam: websocketStreamingParam
29184
- // };
29185
- // }
29186
- // var wsUrl = getPlayParams(data).websocketConnectUrl;
29187
- // if(this.env && this.env.wsUrl) {
29188
- // wsUrl = this.env.wsUrl;
29189
- // }
29190
- // var wsParams = {
29191
- // playURL: getPlayParams(data).websocketStreamingParam
29192
- // };
29193
-
29194
- // this.jSPlugin.JS_Play(wsUrl, wsParams, 0).then(() => {
29195
- // console.log("播放成功");
29196
- // this.pluginStatus.loadingClear();
29197
- // if (this.Theme) {
29198
- // this.Theme.setDecoderState({ play: true });
29199
- // }
29200
- // if (this.audio) {
29201
- // setTimeout(() => {
29202
- // this.openSound();
29203
- // }, 500);
29204
- // }
29205
- // if (typeof this.params.handleSuccess === 'function') {
29206
- // this.params.handleSuccess({
29207
- // retcode: 0,
29208
- // id: this.params.id,
29209
- // type: "handleSuccess"
29210
- // });
29211
- // }
29212
- // resolve(true);
29213
- // }, (err) => {
29214
- // var errorInfo = this.errorHander.matchErrorInfo(err.oError.errorCode);
29215
- // var msg = errorInfo ? errorInfo.description : '播放失败,请检查设备及客户端网络';
29216
- // this.pluginStatus.loadingSetText({
29217
- // text: msg,
29218
- // color: 'red'
29219
- // });
29220
- // if (typeof this.params.handleError === 'function') {
29221
- // this.params.handleError({
29222
- // retcode: err.oError.errorCode,
29223
- // msg: msg,
29224
- // id: this.params.id,
29225
- // type: "handleError"
29226
- // });
29227
- // }
29228
- // reject(false);
29229
- // });
29230
29286
  })
29231
29287
  .catch((err) => {
29232
29288
  var msg = err.msg ? err.msg : '播放失败,请检查设备及客户端网络';
@@ -29543,6 +29599,53 @@ class EZUIKitPlayer {
29543
29599
  });
29544
29600
  }
29545
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
+ }
29546
29649
  var seekRT = this.jSPlugin.JS_Seek(0, startTime, endTime);
29547
29650
  console.log("seekRT", seekRT);
29548
29651
  if (isPromise(seekRT)) {
@@ -29590,6 +29693,19 @@ class EZUIKitPlayer {
29590
29693
  stopTalk() {
29591
29694
  this.Talk.startTalk();
29592
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
+ }
29593
29709
  }
29594
29710
 
29595
29711
  (function (global, factory) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezuikit-js",
3
- "version": "0.4.3",
3
+ "version": "0.4.6",
4
4
  "description": "ezuikit javascript for npm",
5
5
  "main": "ezuikit.js",
6
6
  "scripts": {