ezuikit-js 0.4.2 → 0.4.5

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 +401 -97
  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()) {
@@ -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
 
@@ -24053,7 +24067,8 @@ C11.4,16.3,11,16.6,10.6,16.6z" />
24053
24067
  }
24054
24068
  this.timer = setInterval(() => {
24055
24069
  var getOSDTimePromise = this.jSPlugin.getOSDTime();
24056
- getOSDTimePromise.then((v) => {
24070
+ getOSDTimePromise.then((data) => {
24071
+ var v = data.data;
24057
24072
  if (v === -1) {
24058
24073
  console.log("获取播放时间错误");
24059
24074
  } else {
@@ -26092,12 +26107,19 @@ class Theme {
26092
26107
  this.initThemeData();
26093
26108
  this.renderThemeData();
26094
26109
  break;
26110
+ case 'themeData':
26111
+ this.themeData = this.jSPlugin.params.themeData;
26112
+ this.initThemeData();
26113
+ this.renderThemeData();
26095
26114
  default:
26096
26115
  this.fetchThemeData(this.jSPlugin.themeId);
26097
26116
  break;
26098
26117
  }
26099
26118
  }
26100
- 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) {
26101
26123
  if (this.isMobile) {
26102
26124
  this.Rec = new MobileRec(jSPlugin);
26103
26125
  } else {
@@ -26107,7 +26129,7 @@ class Theme {
26107
26129
  if (!this.jSPlugin.Talk) {
26108
26130
  this.jSPlugin.Talk = new Talk(this.jSPlugin);
26109
26131
  }
26110
- if (this.decoderState.state.type === 'live') {
26132
+ if (matchEzopenUrl(jSPlugin.url).type === 'live') {
26111
26133
  if (this.isMobile) {
26112
26134
  this.MobilePtz = new MobilePtz(jSPlugin);
26113
26135
  this.Ptz = new Ptz(jSPlugin);
@@ -26198,7 +26220,7 @@ class Theme {
26198
26220
  }
26199
26221
  break;
26200
26222
  case 'sound':
26201
- if (`${this.jSPlugin.id}-sound`) {
26223
+ if (document.getElementById(`${this.jSPlugin.id}-sound`)) {
26202
26224
  if (options[item]) {
26203
26225
  document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[1].style = "display:inline-block";
26204
26226
  document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[0].style = "display:none";
@@ -26988,6 +27010,43 @@ class Theme {
26988
27010
  }
26989
27011
  }
26990
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
+
26991
27050
  /**
26992
27051
  * EZUIKitPlayer for npm
26993
27052
  */
@@ -28587,22 +28646,28 @@ var EZUIKitV3$1 = EZUIKitV3;
28587
28646
 
28588
28647
  // iframe模板 - 兼容旧版本
28589
28648
  const matchTemplate = (templateName, params) => {
28590
- const IFRAMETEMPLATE = ['simple','standard','security','vioce','theme'];
28591
- const LOCALTEMPLATE = ['pcLive','pcRec','mobileLive','mobileRec','noData'];
28592
- if(typeof templateName === 'undefined') {
28649
+ const IFRAMETEMPLATE = ['simple', 'standard', 'security', 'vioce', '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
+ }
28593
28658
  return {
28594
28659
  templateType: 'local',
28595
28660
  templateId: ''
28596
28661
  }
28597
28662
  } if (typeof templateName === 'string') {
28598
28663
 
28599
- if(templateName.length === 32) {
28664
+ if (templateName.length === 32) {
28600
28665
  return {
28601
28666
  templateType: 'remote',
28602
28667
  templateId: templateName
28603
28668
  }
28604
28669
  } else if (IFRAMETEMPLATE.indexOf(templateName) !== -1) {
28605
- // 精简版且不使用头部,底部,仅播放视频,建议使用按需加载避免iframe内存额外消耗
28670
+ // 精简版且不使用头部,底部,仅播放视频,建议使用按需加载避免iframe内存额外消耗
28606
28671
  if (templateName === 'simple' && typeof params.header === 'undefined' && typeof params.footer === 'undefined') {
28607
28672
  return {
28608
28673
  templateType: 'local',
@@ -28626,14 +28691,19 @@ class EZUIKitPlayer {
28626
28691
  constructor(params) {
28627
28692
  const { autoplay = true } = params;
28628
28693
  this.params = params;
28629
- window.EZUIKit[params.id] = {state: {
28630
- EZUIKitPlayer: {
28631
- init: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.init || false,
28632
- themeInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.themeInit || false,
28633
- talkInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.talkInit || false
28634
- }}
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
+ }
28635
28702
  };
28636
- if(matchTemplate(this.params.template, params).templateType !== 'iframe'){
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
+ });
28637
28707
  this.id = params.id;
28638
28708
  this.width = params.width;
28639
28709
  this.height = params.height;
@@ -28641,26 +28711,79 @@ class EZUIKitPlayer {
28641
28711
  this.accessToken = params.accessToken;
28642
28712
  this.themeId = matchTemplate(params.template, params).templateId;
28643
28713
  this.id = params.id;
28644
- this.audio = params.audio;
28714
+ this.audio = true;
28715
+ this.poster = params.poster;
28716
+ this.speed = 1;
28645
28717
  this.staticPath = "https://open.ys7.com/assets/ezuikit_v4.0";
28646
- if(typeof params.staticPath === 'string') {
28718
+ if (typeof params.staticPath === 'string') {
28647
28719
  this.staticPath = params.staticPath;
28648
28720
  }
28721
+ if(typeof params.audio !== 'undefined') {
28722
+ this.audio = params.audio;
28723
+ }
28649
28724
  addJs(`${this.staticPath}/js/AudioRenderer.js`, () => {
28650
28725
  addJs(`${this.staticPath}/js/SuperRender_10.js`, () => {
28651
28726
  addJs(`${this.staticPath}/js/jsPlugin-4.0.2.min.js`, () => {
28652
- var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
28653
- initEZUIKitPlayerPromise.then((data) => {
28654
- console.log("初始化成功", data);
28655
- window.EZUIKit[params.id].state.EZUIKitPlayer.init = true;
28656
- if (document.getElementById(`${params.id}canvas_draw0`)) {
28657
- document.getElementById(`${params.id}canvas_draw0`).style.border = "none";
28658
- }
28659
- if (autoplay) {
28660
- //next version 此处可采用promise.all将播放接口部分同步到初始化阶段。
28661
- this.play();
28662
- }
28663
- });
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
+ }
28664
28787
  });
28665
28788
  });
28666
28789
  });
@@ -28731,8 +28854,10 @@ class EZUIKitPlayer {
28731
28854
  },
28732
28855
  windowFullCcreenChange: function (bFull) {
28733
28856
  },
28734
- firstFrameDisplay: function (iWndIndex, iWidth, iHeight) {
28857
+ firstFrameDisplay: (iWndIndex, iWidth, iHeight) => {
28858
+ console.log(iWidth, iHeight);
28735
28859
  jSPlugin.JS_SetCanFullScreen(false);
28860
+ this.pluginStatus.loadingClear();
28736
28861
  },
28737
28862
  performanceLack: function () {
28738
28863
  },
@@ -28740,7 +28865,7 @@ class EZUIKitPlayer {
28740
28865
  }
28741
28866
  };
28742
28867
  // 增加视频容器
28743
- var pluginStatus = new Status(id);
28868
+ var pluginStatus = new Status(this, id);
28744
28869
  pluginStatus.loadingStart(id);
28745
28870
  pluginStatus.loadingSetText({ text: '初始化播放器完成' });
28746
28871
  this.env = {
@@ -29065,67 +29190,99 @@ class EZUIKitPlayer {
29065
29190
  return new Date(date.replace(/-/g, '/')).getTime();
29066
29191
  }
29067
29192
  }
29068
- play() {
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
+ }
29069
29282
  const promise = new Promise((resolve, reject) => {
29070
29283
  this._getRealUrlPromise(this.accessToken, this.url)
29071
29284
  .then((data) => {
29072
- console.log("get real url result ===", data);
29073
- function getPlayParams(url) {
29074
- var websocketConnectUrl = url.split('?')[0].replace('/live', '').replace('/playback', '');
29075
- var websocketStreamingParam = (url.indexOf('/live') === -1 ? (url.indexOf('cloudplayback') !== -1 ? '/cloudplayback?' : '/playback?') : '/live?') + url.split('?')[1];
29076
- if (websocketStreamingParam.indexOf('/playback') !== -1) {
29077
- websocketStreamingParam = websocketStreamingParam.replace("stream=2", 'stream=1');
29078
- }
29079
- // 本地回放仅支持主码流
29080
- return {
29081
- websocketConnectUrl: websocketConnectUrl,
29082
- websocketStreamingParam: websocketStreamingParam
29083
- };
29084
- }
29085
- var wsUrl = getPlayParams(data).websocketConnectUrl;
29086
- if(this.env && this.env.wsUrl) {
29087
- wsUrl = this.env.wsUrl;
29088
- }
29089
- var wsParams = {
29090
- playURL: getPlayParams(data).websocketStreamingParam
29091
- };
29092
-
29093
- this.jSPlugin.JS_Play(wsUrl, wsParams, 0).then(() => {
29094
- console.log("播放成功");
29095
- this.pluginStatus.loadingClear();
29096
- if (this.Theme) {
29097
- this.Theme.setDecoderState({ play: true });
29098
- }
29099
- if (this.audio) {
29100
- setTimeout(() => {
29101
- this.openSound();
29102
- }, 500);
29103
- }
29104
- if (typeof this.params.handleSuccess === 'function') {
29105
- this.params.handleSuccess({
29106
- retcode: 0,
29107
- id: this.params.id,
29108
- type: "handleSuccess"
29109
- });
29110
- }
29111
- resolve(true);
29112
- }, (err) => {
29113
- var errorInfo = this.errorHander.matchErrorInfo(err.oError.errorCode);
29114
- var msg = errorInfo ? errorInfo.description : '播放失败,请检查设备及客户端网络';
29115
- this.pluginStatus.loadingSetText({
29116
- text: msg,
29117
- color: 'red'
29118
- });
29119
- if (typeof this.params.handleError === 'function') {
29120
- this.params.handleError({
29121
- retcode: err.oError.errorCode,
29122
- msg: msg,
29123
- id: this.params.id,
29124
- type: "handleError"
29125
- });
29126
- }
29127
- reject(false);
29128
- });
29285
+ this._pluginPlay(data, () => resolve(true), () => reject(false));
29129
29286
  })
29130
29287
  .catch((err) => {
29131
29288
  var msg = err.msg ? err.msg : '播放失败,请检查设备及客户端网络';
@@ -29241,21 +29398,29 @@ class EZUIKitPlayer {
29241
29398
  return promise;
29242
29399
  }
29243
29400
  getOSDTime() {
29244
- var promise = new Promise((resolve,reject) => {
29401
+ var promise = new Promise((resolve, reject) => {
29245
29402
  this.jSPlugin.JS_GetOSDTime(0)
29246
- .then((data)=>{
29403
+ .then((data) => {
29247
29404
  resolve({
29248
29405
  code: 0,
29249
29406
  retcode: 0,
29250
29407
  data: data
29251
29408
  });
29409
+ // 兼容旧版本callback
29410
+ if (typeof this.params.getOSDTimeCallBack === 'function') {
29411
+ this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: 0, data: data});
29412
+ }
29252
29413
  })
29253
- .catch(err=>{
29414
+ .catch(err => {
29254
29415
  reject({
29255
29416
  code: -1,
29256
29417
  retcode: -1,
29257
29418
  data: err
29258
29419
  });
29420
+ // 兼容旧版本callback
29421
+ if (typeof this.params.getOSDTimeCallBack === 'function') {
29422
+ this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: -1,data: -1 });
29423
+ }
29259
29424
  });
29260
29425
  });
29261
29426
  return promise;
@@ -29263,6 +29428,15 @@ class EZUIKitPlayer {
29263
29428
  capturePicture(name, callback = false) {
29264
29429
  var capturePictureRT = this.jSPlugin.JS_CapturePicture(0, name, "JPEG", callback, !!callback);
29265
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
+ }
29266
29440
  return capturePictureRT;
29267
29441
  }
29268
29442
  return new Promise(function (resolve) {
@@ -29272,6 +29446,15 @@ class EZUIKitPlayer {
29272
29446
  startSave(name) {
29273
29447
  var startSaveRT = this.jSPlugin.JS_StartSave(0, name);
29274
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
+ }
29275
29458
  return startSaveRT;
29276
29459
  }
29277
29460
  if (this.Theme) {
@@ -29284,6 +29467,15 @@ class EZUIKitPlayer {
29284
29467
  stopSave() {
29285
29468
  var stopSaveRT = this.jSPlugin.JS_StopSave(0);
29286
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
+ }
29287
29479
  return stopSaveRT;
29288
29480
  }
29289
29481
  if (this.Theme) {
@@ -29302,6 +29494,10 @@ class EZUIKitPlayer {
29302
29494
  if (this.Theme) {
29303
29495
  this.Theme.setDecoderState({ sound: true });
29304
29496
  }
29497
+ // 兼容旧版本callback
29498
+ if (typeof this.params.openSoundCallBack === 'function') {
29499
+ this.params.openSoundCallBack({ id: this.id, type: 'openSound', code: openSoundRT });
29500
+ }
29305
29501
  return new Promise(function (resolve) {
29306
29502
  resolve(openSoundRT);
29307
29503
  });
@@ -29314,6 +29510,10 @@ class EZUIKitPlayer {
29314
29510
  if (this.Theme) {
29315
29511
  this.Theme.setDecoderState({ sound: false });
29316
29512
  }
29513
+ // 兼容旧版本callback
29514
+ if (typeof this.params.closeSoundCallBack === 'function') {
29515
+ this.params.closeSoundCallBack({ id: this.id, type: 'closeSound', code: closeSoundRT });
29516
+ }
29317
29517
  return new Promise(function (resolve) {
29318
29518
  resolve(closeSoundRT);
29319
29519
  });
@@ -29336,6 +29536,9 @@ class EZUIKitPlayer {
29336
29536
  resolve(closeZoomRT);
29337
29537
  });
29338
29538
  }
29539
+ setPoster(url) {
29540
+ this.pluginStatus.setPoster(url);
29541
+ }
29339
29542
  reSize(width, height) {
29340
29543
  this.width = width;
29341
29544
  this.height = height;
@@ -29343,27 +29546,107 @@ class EZUIKitPlayer {
29343
29546
  this.jSPlugin.JS_Resize(width, height);
29344
29547
  }
29345
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
+ }
29346
29564
  var fastRT = this.jSPlugin.JS_Fast(0);
29347
- console.log("JS_Fast", fastRT);
29348
29565
  if (isPromise(fastRT)) {
29566
+ this.speed = speed;
29349
29567
  return fastRT;
29350
29568
  }
29351
29569
  return new Promise(function (resolve) {
29570
+ this.speed = speed;
29352
29571
  resolve(fastRT);
29353
29572
  });
29354
29573
  }
29355
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
+ }
29356
29590
  var slowRT = this.jSPlugin.JS_Slow(0);
29357
29591
  console.log("slowRT", slowRT);
29358
29592
  if (isPromise(slowRT)) {
29593
+ this.speed = speed;
29359
29594
  return slowRT;
29360
29595
  }
29361
29596
  return new Promise(function (resolve) {
29597
+ this.speed = speed;
29362
29598
  resolve(slowRT);
29363
29599
  });
29364
29600
  }
29365
29601
  seek(startTime, endTime) {
29366
- var seekRT = this.jSPlugin.JS_Seek(0,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);
29367
29650
  console.log("seekRT", seekRT);
29368
29651
  if (isPromise(seekRT)) {
29369
29652
  return seekRT;
@@ -29377,6 +29660,10 @@ class EZUIKitPlayer {
29377
29660
  promise.then((data) => {
29378
29661
  console.log("全屏promise", window.screen.availWidth);
29379
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
+ }
29380
29667
  });
29381
29668
  // 监听全屏事件触发
29382
29669
  const fullscreenchange = () => {
@@ -29384,6 +29671,10 @@ class EZUIKitPlayer {
29384
29671
  if (!isFullScreen) {
29385
29672
  this.jSPlugin.JS_Resize(this.width, this.height);
29386
29673
  }
29674
+ // 兼容旧版本callback
29675
+ if (typeof this.params.fullScreenChangeCallBack === 'function') {
29676
+ this.params.fullScreenChangeCallBack({ id: this.id, type: 'fullScreen', code: isFullScreen });
29677
+ }
29387
29678
  };
29388
29679
  ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange'].forEach((item) => {
29389
29680
  window.addEventListener(item, (data) => fullscreenchange());
@@ -29402,6 +29693,19 @@ class EZUIKitPlayer {
29402
29693
  stopTalk() {
29403
29694
  this.Talk.startTalk();
29404
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
+ }
29405
29709
  }
29406
29710
 
29407
29711
  (function (global, factory) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezuikit-js",
3
- "version": "0.4.2",
3
+ "version": "0.4.5",
4
4
  "description": "ezuikit javascript for npm",
5
5
  "main": "ezuikit.js",
6
6
  "scripts": {