ezuikit-js 0.4.1 → 0.4.4

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 +326 -95
  2. package/package.json +1 -1
package/ezuikit.js CHANGED
@@ -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
 
@@ -23789,6 +23803,9 @@ var TimeLine$1 = function (jsPlugin) {
23789
23803
  class Rec {
23790
23804
  constructor(jSPlugin) {
23791
23805
  this.jSPlugin = jSPlugin;
23806
+ if(!document.getElementById(`${this.jSPlugin.id}-audioControls`)) {
23807
+ return false;
23808
+ }
23792
23809
  this.currentTimeWidth = 1; //回放时间轴尺度 1~4
23793
23810
  this.timer = null;
23794
23811
  this.date = new Date();
@@ -23909,10 +23926,10 @@ C11.4,16.3,11,16.6,10.6,16.6z" />
23909
23926
  });
23910
23927
  this.syncTimeLine();
23911
23928
  // 加载日期选择器
23912
- addCss("https://open.ys7.com/assets/ezuikit_theme/css/datepicker.min.css");
23913
- addJs("https://open.ys7.com/assets/ezuikit_v2.6.4/js/jquery.min.js", () => {
23914
- addJs("https://open.ys7.com/assets/ezuikit_theme/js/datepicker.js", () => {
23915
- addJs("https://open.ys7.com/assets/ezuikit_theme/js/datepicker.zh-CN.js", () => {
23929
+ addCss(`${this.jSPlugin.staticPath}/rec/datepicker.min.css`);
23930
+ addJs(`${this.jSPlugin.staticPath}/rec/jquery.min.js`, () => {
23931
+ addJs(`${this.jSPlugin.staticPath}/rec/datepicker.js`, () => {
23932
+ addJs(`${this.jSPlugin.staticPath}/rec/datepicker.zh-CN.js`, () => {
23916
23933
  // 日期选择:
23917
23934
  $(`#${this.jSPlugin.id}-datepicker`).datepicker({
23918
23935
  autoShow: false,
@@ -25216,9 +25233,9 @@ class Talk {
25216
25233
  audioRightDOM.setAttribute("controls", true);
25217
25234
  audioRight.appendChild(audioRightDOM);
25218
25235
 
25219
- addJs("https://open.ys7.com/assets/ezuikit_v2.6.4/npm/js/adapeter.js", () => {
25220
- addJs("https://open.ys7.com/assets/ezuikit_v2.6.4/npm/js/janus.js", () => {
25221
- addJs("https://open.ys7.com/assets/ezuikit_v4.0/js/tts-v4.js", () => {
25236
+ addJs(`${this.jSPlugin.staticPath}/talk/adapeter.js`, () => {
25237
+ addJs(`${this.jSPlugin.staticPath}/talk/janus.js`, () => {
25238
+ addJs(`${this.jSPlugin.staticPath}/talk/tts-v4.js`, () => {
25222
25239
  // 临时处理
25223
25240
  window.EZUIKit["handleTalkError"] = {
25224
25241
  handleTalkError: (err)=>{
@@ -28584,22 +28601,22 @@ var EZUIKitV3$1 = EZUIKitV3;
28584
28601
 
28585
28602
  // iframe模板 - 兼容旧版本
28586
28603
  const matchTemplate = (templateName, params) => {
28587
- const IFRAMETEMPLATE = ['simple','standard','security','vioce','theme'];
28588
- const LOCALTEMPLATE = ['pcLive','pcRec','mobileLive','mobileRec','noData'];
28589
- if(typeof templateName === 'undefined') {
28604
+ const IFRAMETEMPLATE = ['simple', 'standard', 'security', 'vioce', 'theme'];
28605
+ const LOCALTEMPLATE = ['pcLive', 'pcRec', 'mobileLive', 'mobileRec', 'noData'];
28606
+ if (typeof templateName === 'undefined') {
28590
28607
  return {
28591
28608
  templateType: 'local',
28592
28609
  templateId: ''
28593
28610
  }
28594
28611
  } if (typeof templateName === 'string') {
28595
28612
 
28596
- if(templateName.length === 32) {
28613
+ if (templateName.length === 32) {
28597
28614
  return {
28598
28615
  templateType: 'remote',
28599
28616
  templateId: templateName
28600
28617
  }
28601
28618
  } else if (IFRAMETEMPLATE.indexOf(templateName) !== -1) {
28602
- // 精简版且不使用头部,底部,仅播放视频,建议使用按需加载避免iframe内存额外消耗
28619
+ // 精简版且不使用头部,底部,仅播放视频,建议使用按需加载避免iframe内存额外消耗
28603
28620
  if (templateName === 'simple' && typeof params.header === 'undefined' && typeof params.footer === 'undefined') {
28604
28621
  return {
28605
28622
  templateType: 'local',
@@ -28623,14 +28640,16 @@ class EZUIKitPlayer {
28623
28640
  constructor(params) {
28624
28641
  const { autoplay = true } = params;
28625
28642
  this.params = params;
28626
- window.EZUIKit[params.id] = {state: {
28627
- EZUIKitPlayer: {
28628
- init: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.init || false,
28629
- themeInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.themeInit || false,
28630
- talkInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.talkInit || false
28631
- }}
28643
+ window.EZUIKit[params.id] = {
28644
+ state: {
28645
+ EZUIKitPlayer: {
28646
+ init: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.init || false,
28647
+ themeInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.themeInit || false,
28648
+ talkInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.talkInit || false
28649
+ }
28650
+ }
28632
28651
  };
28633
- if(matchTemplate(this.params.template, params).templateType !== 'iframe'){
28652
+ if (matchTemplate(this.params.template, params).templateType !== 'iframe') {
28634
28653
  this.id = params.id;
28635
28654
  this.width = params.width;
28636
28655
  this.height = params.height;
@@ -28639,21 +28658,41 @@ class EZUIKitPlayer {
28639
28658
  this.themeId = matchTemplate(params.template, params).templateId;
28640
28659
  this.id = params.id;
28641
28660
  this.audio = params.audio;
28642
- addJs("https://open.ys7.com/assets/ezuikit_v4.0/js/AudioRenderer.js", () => {
28643
- addJs("https://open.ys7.com/assets/ezuikit_v4.0/js/SuperRender_10.js", () => {
28644
- addJs("https://open.ys7.com/assets/ezuikit_v4.0/js/jsPlugin-4.0.1.min.js", () => {
28645
- var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
28646
- initEZUIKitPlayerPromise.then((data) => {
28647
- console.log("初始化成功", data);
28648
- window.EZUIKit[params.id].state.EZUIKitPlayer.init = true;
28649
- if (document.getElementById(`${params.id}canvas_draw0`)) {
28650
- document.getElementById(`${params.id}canvas_draw0`).style.border = "none";
28651
- }
28652
- if (autoplay) {
28653
- //next version 此处可采用promise.all将播放接口部分同步到初始化阶段。
28654
- this.play();
28655
- }
28656
- });
28661
+ this.poster = params.poster;
28662
+ this.speed = 1;
28663
+ this.staticPath = "https://open.ys7.com/assets/ezuikit_v4.0";
28664
+ if (typeof params.staticPath === 'string') {
28665
+ this.staticPath = params.staticPath;
28666
+ }
28667
+ addJs(`${this.staticPath}/js/AudioRenderer.js`, () => {
28668
+ addJs(`${this.staticPath}/js/SuperRender_10.js`, () => {
28669
+ addJs(`${this.staticPath}/js/jsPlugin-4.0.2.min.js`, () => {
28670
+ if (autoplay) {
28671
+ var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
28672
+ var getRealUrlPromise = this._getRealUrlPromise(params.accessToken, params.url);
28673
+ Promise.all([initEZUIKitPlayerPromise, getRealUrlPromise]).then(values => {
28674
+ console.log("values", values);
28675
+ if (values[1]) {
28676
+ this._pluginPlay(values[1],
28677
+ () => { console.log("自动播放成功"); },
28678
+ () => { console.log("自动播放失败"); },
28679
+ );
28680
+ }
28681
+ window.EZUIKit[params.id].state.EZUIKitPlayer.init = true;
28682
+ if (document.getElementById(`${params.id}canvas_draw0`)) {
28683
+ document.getElementById(`${params.id}canvas_draw0`).style.border = "none";
28684
+ }
28685
+ });
28686
+ } else {
28687
+ var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
28688
+ initEZUIKitPlayerPromise.then((data) => {
28689
+ console.log("初始化成功", data);
28690
+ window.EZUIKit[params.id].state.EZUIKitPlayer.init = true;
28691
+ if (document.getElementById(`${params.id}canvas_draw0`)) {
28692
+ document.getElementById(`${params.id}canvas_draw0`).style.border = "none";
28693
+ }
28694
+ });
28695
+ }
28657
28696
  });
28658
28697
  });
28659
28698
  });
@@ -28685,6 +28724,7 @@ class EZUIKitPlayer {
28685
28724
  iMaxSplit: 1,
28686
28725
  iCurrentSplit: 1,
28687
28726
  szBasePath: "",
28727
+ staticPath: params.staticPath,
28688
28728
  oStyle: {
28689
28729
  border: "none",
28690
28730
  background: "#000000"
@@ -28732,7 +28772,7 @@ class EZUIKitPlayer {
28732
28772
  }
28733
28773
  };
28734
28774
  // 增加视频容器
28735
- var pluginStatus = new Status(id);
28775
+ var pluginStatus = new Status(this, id);
28736
28776
  pluginStatus.loadingStart(id);
28737
28777
  pluginStatus.loadingSetText({ text: '初始化播放器完成' });
28738
28778
  this.env = {
@@ -29057,64 +29097,138 @@ class EZUIKitPlayer {
29057
29097
  return new Date(date.replace(/-/g, '/')).getTime();
29058
29098
  }
29059
29099
  }
29060
- play() {
29100
+ _pluginPlay(data, successCallback, errorCallback) {
29101
+ console.log("get real url result ===", data);
29102
+ function getPlayParams(url) {
29103
+ var websocketConnectUrl = url.split('?')[0].replace('/live', '').replace('/playback', '');
29104
+ var websocketStreamingParam = (url.indexOf('/live') === -1 ? (url.indexOf('cloudplayback') !== -1 ? '/cloudplayback?' : '/playback?') : '/live?') + url.split('?')[1];
29105
+ if (websocketStreamingParam.indexOf('/playback') !== -1) {
29106
+ websocketStreamingParam = websocketStreamingParam.replace("stream=2", 'stream=1');
29107
+ }
29108
+ // 本地回放仅支持主码流
29109
+ return {
29110
+ websocketConnectUrl: websocketConnectUrl,
29111
+ websocketStreamingParam: websocketStreamingParam
29112
+ };
29113
+ }
29114
+ var wsUrl = getPlayParams(data).websocketConnectUrl;
29115
+ if (this.env && this.env.wsUrl) {
29116
+ wsUrl = this.env.wsUrl;
29117
+ }
29118
+ var wsParams = {
29119
+ playURL: getPlayParams(data).websocketStreamingParam
29120
+ };
29121
+
29122
+ this.jSPlugin.JS_Play(wsUrl, wsParams, 0).then(() => {
29123
+ console.log("播放成功");
29124
+ this.pluginStatus.loadingClear();
29125
+ if (this.Theme) {
29126
+ this.Theme.setDecoderState({ play: true });
29127
+ }
29128
+ if (this.audio) {
29129
+ setTimeout(() => {
29130
+ this.openSound();
29131
+ }, 500);
29132
+ }
29133
+ if (typeof this.params.handleSuccess === 'function') {
29134
+ this.params.handleSuccess({
29135
+ retcode: 0,
29136
+ id: this.params.id,
29137
+ type: "handleSuccess"
29138
+ });
29139
+ }
29140
+ successCallback();
29141
+ }, (err) => {
29142
+ var errorInfo = this.errorHander.matchErrorInfo(err.oError.errorCode);
29143
+ var msg = errorInfo ? errorInfo.description : '播放失败,请检查设备及客户端网络';
29144
+ this.pluginStatus.loadingSetText({
29145
+ text: msg,
29146
+ color: 'red'
29147
+ });
29148
+ if (typeof this.params.handleError === 'function') {
29149
+ this.params.handleError({
29150
+ retcode: err.oError.errorCode,
29151
+ msg: msg,
29152
+ id: this.params.id,
29153
+ type: "handleError"
29154
+ });
29155
+ }
29156
+ successCallback(errorCallback);
29157
+ });
29158
+ }
29159
+ play(options) {
29160
+ if(options) {
29161
+ if(typeof options.url === 'string') {
29162
+ this.url = options.url;
29163
+ }
29164
+ if(typeof options.accessToken === 'string') {
29165
+ this.accessToken = options.accessToken;
29166
+ }
29167
+ if(this.Theme && (typeof options.url === 'string' || typeof options.accessToken === 'string')) {
29168
+ this.Theme.getDeviceInfo();
29169
+ }
29170
+ }
29061
29171
  const promise = new Promise((resolve, reject) => {
29062
29172
  this._getRealUrlPromise(this.accessToken, this.url)
29063
29173
  .then((data) => {
29064
- console.log("get real url result ===", data);
29065
- function getPlayParams(url) {
29066
- var websocketConnectUrl = url.split('?')[0].replace('/live', '').replace('/playback', '');
29067
- var websocketStreamingParam = (url.indexOf('/live') === -1 ? (url.indexOf('cloudplayback') !== -1 ? '/cloudplayback?' : '/playback?') : '/live?') + url.split('?')[1];
29068
- if (websocketStreamingParam.indexOf('/playback') !== -1) {
29069
- websocketStreamingParam = websocketStreamingParam.replace("stream=2", 'stream=1');
29070
- }
29071
- // 本地回放仅支持主码流
29072
- return {
29073
- websocketConnectUrl: websocketConnectUrl,
29074
- websocketStreamingParam: websocketStreamingParam
29075
- };
29076
- }
29077
- var wsUrl = getPlayParams(data).websocketConnectUrl;
29078
- var wsParams = {
29079
- playURL: getPlayParams(data).websocketStreamingParam
29080
- };
29081
-
29082
- this.jSPlugin.JS_Play(wsUrl, wsParams, 0).then(() => {
29083
- console.log("播放成功");
29084
- this.pluginStatus.loadingClear();
29085
- if (this.Theme) {
29086
- this.Theme.setDecoderState({ play: true });
29087
- }
29088
- if (this.audio) {
29089
- setTimeout(() => {
29090
- this.openSound();
29091
- }, 500);
29092
- }
29093
- if (typeof this.params.handleSuccess === 'function') {
29094
- this.params.handleSuccess({
29095
- retcode: 0,
29096
- id: this.params.id,
29097
- type: "handleSuccess"
29098
- });
29099
- }
29100
- resolve(true);
29101
- }, (err) => {
29102
- var errorInfo = this.errorHander.matchErrorInfo(err.oError.errorCode);
29103
- var msg = errorInfo ? errorInfo.description : '播放失败,请检查设备及客户端网络';
29104
- this.pluginStatus.loadingSetText({
29105
- text: msg,
29106
- color: 'red'
29107
- });
29108
- if (typeof this.params.handleError === 'function') {
29109
- this.params.handleError({
29110
- retcode: err.oError.errorCode,
29111
- msg: msg,
29112
- id: this.params.id,
29113
- type: "handleError"
29114
- });
29115
- }
29116
- reject(false);
29117
- });
29174
+ this._pluginPlay(data, () => resolve(true), () => reject(false));
29175
+ // console.log("get real url result ===", data);
29176
+ // function getPlayParams(url) {
29177
+ // var websocketConnectUrl = url.split('?')[0].replace('/live', '').replace('/playback', '');
29178
+ // var websocketStreamingParam = (url.indexOf('/live') === -1 ? (url.indexOf('cloudplayback') !== -1 ? '/cloudplayback?' : '/playback?') : '/live?') + url.split('?')[1];
29179
+ // if (websocketStreamingParam.indexOf('/playback') !== -1) {
29180
+ // websocketStreamingParam = websocketStreamingParam.replace("stream=2", 'stream=1');
29181
+ // }
29182
+ // // 本地回放仅支持主码流
29183
+ // return {
29184
+ // websocketConnectUrl: websocketConnectUrl,
29185
+ // websocketStreamingParam: websocketStreamingParam
29186
+ // };
29187
+ // }
29188
+ // var wsUrl = getPlayParams(data).websocketConnectUrl;
29189
+ // if(this.env && this.env.wsUrl) {
29190
+ // wsUrl = this.env.wsUrl;
29191
+ // }
29192
+ // var wsParams = {
29193
+ // playURL: getPlayParams(data).websocketStreamingParam
29194
+ // };
29195
+
29196
+ // this.jSPlugin.JS_Play(wsUrl, wsParams, 0).then(() => {
29197
+ // console.log("播放成功");
29198
+ // this.pluginStatus.loadingClear();
29199
+ // if (this.Theme) {
29200
+ // this.Theme.setDecoderState({ play: true });
29201
+ // }
29202
+ // if (this.audio) {
29203
+ // setTimeout(() => {
29204
+ // this.openSound();
29205
+ // }, 500);
29206
+ // }
29207
+ // if (typeof this.params.handleSuccess === 'function') {
29208
+ // this.params.handleSuccess({
29209
+ // retcode: 0,
29210
+ // id: this.params.id,
29211
+ // type: "handleSuccess"
29212
+ // });
29213
+ // }
29214
+ // resolve(true);
29215
+ // }, (err) => {
29216
+ // var errorInfo = this.errorHander.matchErrorInfo(err.oError.errorCode);
29217
+ // var msg = errorInfo ? errorInfo.description : '播放失败,请检查设备及客户端网络';
29218
+ // this.pluginStatus.loadingSetText({
29219
+ // text: msg,
29220
+ // color: 'red'
29221
+ // });
29222
+ // if (typeof this.params.handleError === 'function') {
29223
+ // this.params.handleError({
29224
+ // retcode: err.oError.errorCode,
29225
+ // msg: msg,
29226
+ // id: this.params.id,
29227
+ // type: "handleError"
29228
+ // });
29229
+ // }
29230
+ // reject(false);
29231
+ // });
29118
29232
  })
29119
29233
  .catch((err) => {
29120
29234
  var msg = err.msg ? err.msg : '播放失败,请检查设备及客户端网络';
@@ -29230,28 +29344,45 @@ class EZUIKitPlayer {
29230
29344
  return promise;
29231
29345
  }
29232
29346
  getOSDTime() {
29233
- var promise = new Promise((resolve,reject) => {
29347
+ var promise = new Promise((resolve, reject) => {
29234
29348
  this.jSPlugin.JS_GetOSDTime(0)
29235
- .then((data)=>{
29349
+ .then((data) => {
29236
29350
  resolve({
29237
29351
  code: 0,
29238
29352
  retcode: 0,
29239
29353
  data: data
29240
29354
  });
29355
+ // 兼容旧版本callback
29356
+ if (typeof this.params.getOSDTimeCallBack === 'function') {
29357
+ this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: 0, data: data});
29358
+ }
29241
29359
  })
29242
- .catch(err=>{
29360
+ .catch(err => {
29243
29361
  reject({
29244
29362
  code: -1,
29245
29363
  retcode: -1,
29246
29364
  data: err
29247
29365
  });
29366
+ // 兼容旧版本callback
29367
+ if (typeof this.params.getOSDTimeCallBack === 'function') {
29368
+ this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: -1,data: -1 });
29369
+ }
29248
29370
  });
29249
29371
  });
29250
29372
  return promise;
29251
29373
  }
29252
29374
  capturePicture(name, callback = false) {
29253
- var capturePictureRT = this.jSPlugin.JS_CapturePicture(0, name, "JPEG", callback);
29375
+ var capturePictureRT = this.jSPlugin.JS_CapturePicture(0, name, "JPEG", callback, !!callback);
29254
29376
  if (isPromise(capturePictureRT)) {
29377
+ // 兼容旧版本callback
29378
+ if (typeof this.params.capturePictureCallBack === 'function') {
29379
+ capturePictureRT.then(() => {
29380
+ this.params.capturePictureCallBack({ id: this.id, type: 'capturePicture', code: 0 });
29381
+ })
29382
+ .catch(() => {
29383
+ this.params.capturePictureCallBack({ id: this.id, type: 'capturePicture', code: -1 });
29384
+ });
29385
+ }
29255
29386
  return capturePictureRT;
29256
29387
  }
29257
29388
  return new Promise(function (resolve) {
@@ -29261,6 +29392,15 @@ class EZUIKitPlayer {
29261
29392
  startSave(name) {
29262
29393
  var startSaveRT = this.jSPlugin.JS_StartSave(0, name);
29263
29394
  if (isPromise(startSaveRT)) {
29395
+ // 兼容旧版本callback
29396
+ if (typeof this.params.startSaveCallBack === 'function') {
29397
+ startSaveRT.then(() => {
29398
+ this.params.startSaveCallBack({ id: this.id, type: 'startSave', code: 0 });
29399
+ })
29400
+ .catch(() => {
29401
+ this.params.startSaveCallBack({ id: this.id, type: 'startSave', code: -1 });
29402
+ });
29403
+ }
29264
29404
  return startSaveRT;
29265
29405
  }
29266
29406
  if (this.Theme) {
@@ -29273,6 +29413,15 @@ class EZUIKitPlayer {
29273
29413
  stopSave() {
29274
29414
  var stopSaveRT = this.jSPlugin.JS_StopSave(0);
29275
29415
  if (isPromise(stopSaveRT)) {
29416
+ // 兼容旧版本callback
29417
+ if (typeof this.params.startSaveCallBack === 'function') {
29418
+ stopSaveRT.then(() => {
29419
+ this.params.stopSaveCallBack({ id: this.id, type: 'stopSave', code: 0 });
29420
+ })
29421
+ .catch(() => {
29422
+ this.params.stopSaveCallBack({ id: this.id, type: 'stopSave', code: -1 });
29423
+ });
29424
+ }
29276
29425
  return stopSaveRT;
29277
29426
  }
29278
29427
  if (this.Theme) {
@@ -29291,6 +29440,10 @@ class EZUIKitPlayer {
29291
29440
  if (this.Theme) {
29292
29441
  this.Theme.setDecoderState({ sound: true });
29293
29442
  }
29443
+ // 兼容旧版本callback
29444
+ if (typeof this.params.openSoundCallBack === 'function') {
29445
+ this.params.openSoundCallBack({ id: this.id, type: 'openSound', code: openSoundRT });
29446
+ }
29294
29447
  return new Promise(function (resolve) {
29295
29448
  resolve(openSoundRT);
29296
29449
  });
@@ -29303,6 +29456,10 @@ class EZUIKitPlayer {
29303
29456
  if (this.Theme) {
29304
29457
  this.Theme.setDecoderState({ sound: false });
29305
29458
  }
29459
+ // 兼容旧版本callback
29460
+ if (typeof this.params.closeSoundCallBack === 'function') {
29461
+ this.params.closeSoundCallBack({ id: this.id, type: 'closeSound', code: closeSoundRT });
29462
+ }
29306
29463
  return new Promise(function (resolve) {
29307
29464
  resolve(closeSoundRT);
29308
29465
  });
@@ -29325,17 +29482,87 @@ class EZUIKitPlayer {
29325
29482
  resolve(closeZoomRT);
29326
29483
  });
29327
29484
  }
29485
+ setPoster(url) {
29486
+ this.pluginStatus.setPoster(url);
29487
+ }
29328
29488
  reSize(width, height) {
29329
29489
  this.width = width;
29330
29490
  this.height = height;
29331
29491
  document.getElementById(`${this.id}-wrap`).style = `width:${width}px;position:relative;`;
29332
29492
  this.jSPlugin.JS_Resize(width, height);
29333
29493
  }
29494
+ fast() {
29495
+ var speed = this.speed;
29496
+ if (speed === 1) {
29497
+ speed = 2;
29498
+ } else if (speed === 2) {
29499
+ speed = 4;
29500
+ } else {
29501
+ if (typeof this.params.handleError === 'function') {
29502
+ this.params.handleError({
29503
+ msg: "播放速度最大为4倍速度",
29504
+ retcode: 1003,
29505
+ id: this.id,
29506
+ type: "handleError"
29507
+ });
29508
+ }
29509
+ }
29510
+ var fastRT = this.jSPlugin.JS_Fast(0);
29511
+ if (isPromise(fastRT)) {
29512
+ this.speed = speed;
29513
+ return fastRT;
29514
+ }
29515
+ return new Promise(function (resolve) {
29516
+ this.speed = speed;
29517
+ resolve(fastRT);
29518
+ });
29519
+ }
29520
+ slow() {
29521
+ var speed = this.speed;
29522
+ if (speed === 4) {
29523
+ speed = 2;
29524
+ } else if (speed === 2) {
29525
+ speed = 1;
29526
+ } else {
29527
+ if (typeof this.params.handleError === 'function') {
29528
+ this.params.handleError({
29529
+ msg: "播放速度最小为1倍速度",
29530
+ retcode: 1003,
29531
+ id: this.id,
29532
+ type: "handleError"
29533
+ });
29534
+ }
29535
+ }
29536
+ var slowRT = this.jSPlugin.JS_Slow(0);
29537
+ console.log("slowRT", slowRT);
29538
+ if (isPromise(slowRT)) {
29539
+ this.speed = speed;
29540
+ return slowRT;
29541
+ }
29542
+ return new Promise(function (resolve) {
29543
+ this.speed = speed;
29544
+ resolve(slowRT);
29545
+ });
29546
+ }
29547
+ seek(startTime, endTime) {
29548
+ var seekRT = this.jSPlugin.JS_Seek(0, startTime, endTime);
29549
+ console.log("seekRT", seekRT);
29550
+ if (isPromise(seekRT)) {
29551
+ return seekRT;
29552
+ }
29553
+ return new Promise(function (resolve) {
29554
+ resolve(seekRT);
29555
+ });
29556
+ }
29334
29557
  fullScreen() {
29335
29558
  var promise = requestFullScreenPromise(document.getElementById(`${this.id}`));
29336
29559
  promise.then((data) => {
29337
29560
  console.log("全屏promise", window.screen.availWidth);
29338
29561
  this.jSPlugin.JS_Resize(window.screen.availWidth, window.screen.availHeight);
29562
+ // 兼容旧版本callback
29563
+ if (typeof this.params.fullScreenCallBack === 'function') {
29564
+ this.params.fullScreenCallBack({ id: this.id, type: 'fullScreen', code: 0 });
29565
+ }
29339
29566
  });
29340
29567
  // 监听全屏事件触发
29341
29568
  const fullscreenchange = () => {
@@ -29343,6 +29570,10 @@ class EZUIKitPlayer {
29343
29570
  if (!isFullScreen) {
29344
29571
  this.jSPlugin.JS_Resize(this.width, this.height);
29345
29572
  }
29573
+ // 兼容旧版本callback
29574
+ if (typeof this.params.fullScreenChangeCallBack === 'function') {
29575
+ this.params.fullScreenChangeCallBack({ id: this.id, type: 'fullScreen', code: isFullScreen });
29576
+ }
29346
29577
  };
29347
29578
  ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange'].forEach((item) => {
29348
29579
  window.addEventListener(item, (data) => fullscreenchange());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezuikit-js",
3
- "version": "0.4.1",
3
+ "version": "0.4.4",
4
4
  "description": "ezuikit javascript for npm",
5
5
  "main": "ezuikit.js",
6
6
  "scripts": {