@volcengine/veplayer 2.4.3-rc.0 → 2.4.5-rc.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.
@@ -1311,7 +1311,7 @@ var __publicField = (obj, key, value) => {
1311
1311
  android: /(Android)\s([\d.]+)/,
1312
1312
  ios: /(Version)\/([\d.]+)/
1313
1313
  };
1314
- var H264_MIMETYPES = ["avc1.42E01E, mp4a.40.2", "avc1.58A01E, mp4a.40.2", "avc1.4D401E, mp4a.40.2", "avc1.64001E, mp4a.40.2", "avc1.42E01E", "mp4v.20.8", "mp4v.20.8, mp4a.40.2", "mp4v.20.240, mp4a.40.2"];
1314
+ var H264_MIMETYPES = ["avc1.42E01E, mp4a.40.2", "avc1.58A01E, mp4a.40.2", "avc1.4D401E, mp4a.40.2", "avc1.64001E, mp4a.40.2", "avc1.42E01E", "mp4v.20.8", "avc1.42E01E, mp4a.40.2", "avc1.58A01E, mp4a.40.2", "avc1.4D401E, mp4a.40.2", "avc1.64001E, mp4a.40.2", "mp4v.20.8, mp4a.40.2", "mp4v.20.240, mp4a.40.2"];
1315
1315
  var sniffer = {
1316
1316
  get device() {
1317
1317
  var r = sniffer.os;
@@ -1456,7 +1456,7 @@ var __publicField = (obj, key, value) => {
1456
1456
  }
1457
1457
  }
1458
1458
  };
1459
- var version = "3.0.20-rc.6";
1459
+ var version = "3.0.19-rc.0";
1460
1460
  var ERROR_TYPE_MAP = {
1461
1461
  1: "media",
1462
1462
  2: "media",
@@ -2426,7 +2426,8 @@ var __publicField = (obj, key, value) => {
2426
2426
  }
2427
2427
  if (this.__hooks && this.__hooks[hookName]) {
2428
2428
  try {
2429
- var preRet = runHooks(this, hookName, handler);
2429
+ var _this$__hooks$hookNam;
2430
+ var preRet = (_this$__hooks$hookNam = this.__hooks[hookName]).call.apply(_this$__hooks$hookNam, [this, this].concat(Array.prototype.slice.call(arguments)));
2430
2431
  if (preRet) {
2431
2432
  if (preRet.then) {
2432
2433
  preRet.then(function(isContinue) {
@@ -2451,19 +2452,6 @@ var __publicField = (obj, key, value) => {
2451
2452
  }
2452
2453
  }.bind(this);
2453
2454
  }
2454
- function findHookIndex(hookName, handler) {
2455
- var __hooks = this.__hooks;
2456
- if (!__hooks || !Array.isArray(__hooks[hookName])) {
2457
- return -1;
2458
- }
2459
- var hookHandlers = __hooks[hookName];
2460
- for (var i = 0; i < hookHandlers.length; i++) {
2461
- if (hookHandlers[i] === handler) {
2462
- return i;
2463
- }
2464
- }
2465
- return -1;
2466
- }
2467
2455
  function useHooks(hookName, handler) {
2468
2456
  var __hooks = this.__hooks;
2469
2457
  if (!__hooks) {
@@ -2473,12 +2461,7 @@ var __publicField = (obj, key, value) => {
2473
2461
  console.warn("has no supported hook which name [".concat(hookName, "]"));
2474
2462
  return false;
2475
2463
  }
2476
- if (!Array.isArray(__hooks[hookName])) {
2477
- __hooks[hookName] = [];
2478
- }
2479
- if (findHookIndex.call(this, hookName, handler) === -1) {
2480
- __hooks[hookName].push(handler);
2481
- }
2464
+ __hooks && (__hooks[hookName] = handler);
2482
2465
  return true;
2483
2466
  }
2484
2467
  function removeHooks(hookName, handler) {
@@ -2486,13 +2469,6 @@ var __publicField = (obj, key, value) => {
2486
2469
  if (!__hooks) {
2487
2470
  return;
2488
2471
  }
2489
- if (Array.isArray(__hooks[hookName])) {
2490
- var hooks = __hooks[hookName];
2491
- var index = findHookIndex.call(this, hookName, handler);
2492
- if (index !== -1) {
2493
- hooks.splice(index, 1);
2494
- }
2495
- }
2496
2472
  delete __hooks[hookName];
2497
2473
  }
2498
2474
  function usePluginHooks(pluginName) {
@@ -2540,30 +2516,18 @@ var __publicField = (obj, key, value) => {
2540
2516
  for (var _len5 = arguments.length, args = new Array(_len5 > 3 ? _len5 - 3 : 0), _key5 = 3; _key5 < _len5; _key5++) {
2541
2517
  args[_key5 - 3] = arguments[_key5];
2542
2518
  }
2543
- if (obj.__hooks && Array.isArray(obj.__hooks[hookName])) {
2544
- var hooks = obj.__hooks[hookName];
2545
- var index = -1;
2546
- var runHooksRecursive = function runHooksRecursive2(obj2, hookName2, handler2) {
2547
- for (var _len6 = arguments.length, args2 = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) {
2548
- args2[_key6 - 3] = arguments[_key6];
2549
- }
2550
- index++;
2551
- if (hooks.length === 0 || index === hooks.length) {
2552
- return handler2.call.apply(handler2, [obj2, obj2].concat(args2));
2553
- }
2554
- var hook2 = hooks[index];
2555
- var ret = hook2.call.apply(hook2, [obj2, obj2].concat(args2));
2556
- if (ret && ret.then) {
2557
- return ret.then(function(data) {
2558
- return data === false ? null : runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
2559
- }).catch(function(e) {
2560
- console.warn("[runHooks]".concat(hookName2, " reject"), e.message);
2561
- });
2562
- } else if (ret !== false) {
2563
- return runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
2564
- }
2565
- };
2566
- return runHooksRecursive.apply(void 0, [obj, hookName, handler].concat(args));
2519
+ if (obj.__hooks && obj.__hooks[hookName]) {
2520
+ var _obj$__hooks$hookName;
2521
+ var ret = (_obj$__hooks$hookName = obj.__hooks[hookName]).call.apply(_obj$__hooks$hookName, [obj, obj].concat(args));
2522
+ if (ret && ret.then) {
2523
+ ret.then(function(data) {
2524
+ return data === false ? null : handler.call.apply(handler, [obj, obj].concat(args));
2525
+ }).catch(function(e) {
2526
+ console.warn("[runHooks]".concat(hookName, " reject"), e.message);
2527
+ });
2528
+ } else if (ret !== false) {
2529
+ return handler.call.apply(handler, [obj, obj].concat(args));
2530
+ }
2567
2531
  } else {
2568
2532
  return handler.call.apply(handler, [obj, obj].concat(args));
2569
2533
  }
@@ -2807,18 +2771,6 @@ var __publicField = (obj, key, value) => {
2807
2771
  }
2808
2772
  }
2809
2773
  }
2810
- }, {
2811
- key: "defineMethod",
2812
- value: function defineMethod(Obj, map) {
2813
- for (var key in map) {
2814
- if (Object.prototype.hasOwnProperty.call(map, key) && typeof map[key] === "function") {
2815
- Object.defineProperty(Obj, key, {
2816
- configurable: true,
2817
- value: map[key]
2818
- });
2819
- }
2820
- }
2821
- }
2822
2774
  }, {
2823
2775
  key: "defaultConfig",
2824
2776
  get: function get() {
@@ -3464,7 +3416,7 @@ var __publicField = (obj, key, value) => {
3464
3416
  if (!this.observer) {
3465
3417
  return;
3466
3418
  }
3467
- this.observer.observe(target);
3419
+ this.observer && this.observer.observe(target);
3468
3420
  var _pid = target.getAttribute(PLATER_ID);
3469
3421
  var __handlers = this.__handlers;
3470
3422
  var index = -1;
@@ -3493,17 +3445,16 @@ var __publicField = (obj, key, value) => {
3493
3445
  }
3494
3446
  });
3495
3447
  try {
3496
- var _this$observer;
3497
- (_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.unobserve(target);
3448
+ this.observer && this.observer.unobserve(target);
3498
3449
  } catch (e) {
3499
3450
  }
3451
+ this.observer && this.observer.unobserve(target);
3500
3452
  i > -1 && this.__handlers.splice(i, 1);
3501
3453
  }
3502
3454
  }, {
3503
3455
  key: "destroyObserver",
3504
3456
  value: function destroyObserver() {
3505
- var _this$observer2;
3506
- (_this$observer2 = this.observer) === null || _this$observer2 === void 0 ? void 0 : _this$observer2.disconnect();
3457
+ this.observer && this.observer.disconnect();
3507
3458
  this.observer = null;
3508
3459
  this.__handlers = null;
3509
3460
  }
@@ -3535,8 +3486,7 @@ var __publicField = (obj, key, value) => {
3535
3486
  return resizeObserver;
3536
3487
  }
3537
3488
  function unObserver(target, handler) {
3538
- var _resizeObserver;
3539
- (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.unObserver(target, handler);
3489
+ resizeObserver.unObserver(target, handler);
3540
3490
  }
3541
3491
  var pluginsManager = {
3542
3492
  pluginGroup: {},
@@ -4534,7 +4484,10 @@ var __publicField = (obj, key, value) => {
4534
4484
  }
4535
4485
  var _this$config = _this.config, autoplay2 = _this$config.autoplay, defaultPlaybackRate = _this$config.defaultPlaybackRate;
4536
4486
  XG_DEBUG.logInfo("player", "canPlayFunc, startTime", _this.__startTime);
4537
- _this._seekToStartTime();
4487
+ if (_this.__startTime > 0 && _this.duration > 0) {
4488
+ _this.currentTime = _this.__startTime > _this.duration ? _this.duration : _this.__startTime;
4489
+ _this.__startTime = -1;
4490
+ }
4538
4491
  _this.playbackRate = defaultPlaybackRate;
4539
4492
  (autoplay2 || _this._useAutoplay) && _this.mediaPlay();
4540
4493
  _this.off(CANPLAY, _this.canPlayFunc);
@@ -4624,7 +4577,6 @@ var __publicField = (obj, key, value) => {
4624
4577
  _this.waitTimer = null;
4625
4578
  _this.handleSource = true;
4626
4579
  _this._state = STATES.INITIAL;
4627
- _this.isAd = false;
4628
4580
  _this.isError = false;
4629
4581
  _this._hasStart = false;
4630
4582
  _this.isSeeking = false;
@@ -5009,8 +4961,7 @@ var __publicField = (obj, key, value) => {
5009
4961
  _pConfig.position && (options.position = _pConfig.position);
5010
4962
  var position = options.position ? options.position : options.config && options.config.position || PLUFGIN.defaultConfig && PLUFGIN.defaultConfig.position;
5011
4963
  if (!options.root && typeof position === "string" && position.indexOf("controls") > -1) {
5012
- var _this$controls;
5013
- return (_this$controls = this.controls) === null || _this$controls === void 0 ? void 0 : _this$controls.registerPlugin(PLUFGIN, options, PLUFGIN.pluginName);
4964
+ return this.controls && this.controls.registerPlugin(PLUFGIN, options, PLUFGIN.pluginName);
5014
4965
  }
5015
4966
  if (!options.root) {
5016
4967
  options.root = this._getRootByPosition(position);
@@ -5158,7 +5109,10 @@ var __publicField = (obj, key, value) => {
5158
5109
  reject(e);
5159
5110
  };
5160
5111
  var _canplay = function _canplay2() {
5161
- _this9._seekToStartTime();
5112
+ if (_this9.duration > 0 && _this9.__startTime > 0) {
5113
+ _this9.currentTime = _this9.__startTime;
5114
+ _this9.__startTime = -1;
5115
+ }
5162
5116
  if (isPaused) {
5163
5117
  _this9.pause();
5164
5118
  }
@@ -5779,17 +5733,11 @@ var __publicField = (obj, key, value) => {
5779
5733
  }, {
5780
5734
  key: "onLoadeddata",
5781
5735
  value: function onLoadeddata() {
5782
- var _this22 = this;
5783
5736
  this.isError = false;
5784
5737
  this.isSeeking = false;
5785
- if (this.__startTime > 0) {
5786
- if (this.duration > 0) {
5787
- this._seekToStartTime();
5788
- } else {
5789
- this.once(DURATION_CHANGE, function() {
5790
- _this22._seekToStartTime();
5791
- });
5792
- }
5738
+ if (this.__startTime > 0 && this.duration > 0) {
5739
+ this.currentTime = this.__startTime;
5740
+ this.__startTime = -1;
5793
5741
  }
5794
5742
  }
5795
5743
  }, {
@@ -5858,27 +5806,27 @@ var __publicField = (obj, key, value) => {
5858
5806
  }, {
5859
5807
  key: "onWaiting",
5860
5808
  value: function onWaiting() {
5861
- var _this23 = this;
5809
+ var _this22 = this;
5862
5810
  if (this.waitTimer) {
5863
5811
  util.clearTimeout(this, this.waitTimer);
5864
5812
  }
5865
5813
  this.updateAcc("waiting");
5866
5814
  this.waitTimer = util.setTimeout(this, function() {
5867
- _this23.addClass(STATE_CLASS.LOADING);
5868
- _this23.emit(LOADING);
5869
- util.clearTimeout(_this23, _this23.waitTimer);
5870
- _this23.waitTimer = null;
5815
+ _this22.addClass(STATE_CLASS.LOADING);
5816
+ _this22.emit(LOADING);
5817
+ util.clearTimeout(_this22, _this22.waitTimer);
5818
+ _this22.waitTimer = null;
5871
5819
  }, this.config.minWaitDelay);
5872
5820
  }
5873
5821
  }, {
5874
5822
  key: "onPlaying",
5875
5823
  value: function onPlaying() {
5876
- var _this24 = this;
5824
+ var _this23 = this;
5877
5825
  this.isError = false;
5878
5826
  var NO_START = STATE_CLASS.NO_START, PAUSED = STATE_CLASS.PAUSED, ENDED2 = STATE_CLASS.ENDED, ERROR2 = STATE_CLASS.ERROR, REPLAY2 = STATE_CLASS.REPLAY, LOADING2 = STATE_CLASS.LOADING;
5879
5827
  var clsList = [NO_START, PAUSED, ENDED2, ERROR2, REPLAY2, LOADING2];
5880
5828
  clsList.forEach(function(cls) {
5881
- _this24.removeClass(cls);
5829
+ _this23.removeClass(cls);
5882
5830
  });
5883
5831
  if (!this._accPlayed.t && !this.paused && !this.ended) {
5884
5832
  this._accPlayed.t = (/* @__PURE__ */ new Date()).getTime();
@@ -6039,14 +5987,14 @@ var __publicField = (obj, key, value) => {
6039
5987
  }, {
6040
5988
  key: "setConfig",
6041
5989
  value: function setConfig(config) {
6042
- var _this25 = this;
5990
+ var _this24 = this;
6043
5991
  if (!config) {
6044
5992
  return;
6045
5993
  }
6046
5994
  Object.keys(config).map(function(key) {
6047
5995
  if (key !== "plugins") {
6048
- _this25.config[key] = config[key];
6049
- var plugin = _this25.plugins[key.toLowerCase()];
5996
+ _this24.config[key] = config[key];
5997
+ var plugin = _this24.plugins[key.toLowerCase()];
6050
5998
  if (plugin && util.typeOf(plugin.setConfig) === "Function") {
6051
5999
  plugin.setConfig(config[key]);
6052
6000
  }
@@ -6056,20 +6004,20 @@ var __publicField = (obj, key, value) => {
6056
6004
  }, {
6057
6005
  key: "playNext",
6058
6006
  value: function playNext(config) {
6059
- var _this26 = this;
6007
+ var _this25 = this;
6060
6008
  this.resetState();
6061
6009
  this.setConfig(config);
6062
6010
  this._currentTime = 0;
6063
6011
  this._duration = 0;
6064
6012
  runHooks(this, "playnext", function() {
6065
- _this26.start();
6066
- _this26.emit(PLAYNEXT, config);
6013
+ _this25.start();
6014
+ _this25.emit(PLAYNEXT, config);
6067
6015
  });
6068
6016
  }
6069
6017
  }, {
6070
6018
  key: "resize",
6071
6019
  value: function resize() {
6072
- var _this27 = this;
6020
+ var _this26 = this;
6073
6021
  if (!this.media) {
6074
6022
  return;
6075
6023
  }
@@ -6109,7 +6057,7 @@ var __publicField = (obj, key, value) => {
6109
6057
  }
6110
6058
  if (!this.fullscreen && !this.cssfullscreen) {
6111
6059
  Object.keys(_style).forEach(function(key) {
6112
- _this27.root.style[key] = _style[key];
6060
+ _this26.root.style[key] = _style[key];
6113
6061
  });
6114
6062
  }
6115
6063
  if (videoFillMode === "fillHeight" && fit < videoFit || videoFillMode === "fillWidth" && fit > videoFit) {
@@ -6151,14 +6099,6 @@ var __publicField = (obj, key, value) => {
6151
6099
  url
6152
6100
  };
6153
6101
  }
6154
- }, {
6155
- key: "_seekToStartTime",
6156
- value: function _seekToStartTime() {
6157
- if (this.__startTime > 0 && this.duration > 0) {
6158
- this.currentTime = this.__startTime > this.duration ? this.duration : this.__startTime;
6159
- this.__startTime = -1;
6160
- }
6161
- }
6162
6102
  }, {
6163
6103
  key: "state",
6164
6104
  get: function get() {
@@ -6209,15 +6149,15 @@ var __publicField = (obj, key, value) => {
6209
6149
  return this.config.definition.list || [];
6210
6150
  },
6211
6151
  set: function set(list) {
6212
- var _this28 = this;
6152
+ var _this27 = this;
6213
6153
  var definition = this.config.definition;
6214
6154
  var curDef = null;
6215
6155
  var targetDef = null;
6216
6156
  definition.list = list;
6217
6157
  this.emit("resourceReady", list);
6218
6158
  list.forEach(function(item) {
6219
- var _this28$curDefinition;
6220
- if (((_this28$curDefinition = _this28.curDefinition) === null || _this28$curDefinition === void 0 ? void 0 : _this28$curDefinition.definition) === item.definition) {
6159
+ var _this27$curDefinition;
6160
+ if (((_this27$curDefinition = _this27.curDefinition) === null || _this27$curDefinition === void 0 ? void 0 : _this27$curDefinition.definition) === item.definition) {
6221
6161
  curDef = item;
6222
6162
  }
6223
6163
  if (definition.defaultDefinition === item.definition) {
@@ -6713,11 +6653,11 @@ var __publicField = (obj, key, value) => {
6713
6653
  } : error2;
6714
6654
  const message = (i18n == null ? void 0 : i18n.getText(errorInfo == null ? void 0 : errorInfo.messageTextKey)) ?? (errorInfo == null ? void 0 : errorInfo.message) ?? ((_a = errorInfo == null ? void 0 : errorInfo.error) == null ? void 0 : _a.message) ?? (i18n == null ? void 0 : i18n.getText("UNKNOWN"));
6715
6655
  super(message);
6716
- /**
6656
+ /** {zh}
6717
6657
  * @brief 错误码。
6718
6658
  */
6719
6659
  /** {en}
6720
- * @brief The error code.
6660
+ * @brief Error code.
6721
6661
  */
6722
6662
  __publicField(this, "errorCode");
6723
6663
  /** {zh}
@@ -6954,7 +6894,7 @@ var __publicField = (obj, key, value) => {
6954
6894
  var className = _this.config.mode === "auto" ? "auto-hide" : "hide";
6955
6895
  util.addClass(_this.root, className);
6956
6896
  _this.autoPlayStart = true;
6957
- _this.toggleTo("play");
6897
+ _this.onPlayPause("play");
6958
6898
  });
6959
6899
  _this.autoPlayStart = false;
6960
6900
  return _this;
@@ -6962,19 +6902,9 @@ var __publicField = (obj, key, value) => {
6962
6902
  _createClass(Start2, [{
6963
6903
  key: "afterCreate",
6964
6904
  value: function afterCreate() {
6965
- var playerConfig = this.playerConfig;
6966
- this.initIcons();
6967
- this.listenEvents();
6968
- this.bindClickEvents();
6969
- if (!playerConfig.autoplay) {
6970
- this.show();
6971
- }
6972
- }
6973
- }, {
6974
- key: "listenEvents",
6975
- value: function listenEvents() {
6976
6905
  var _this2 = this;
6977
6906
  var player = this.player, playerConfig = this.playerConfig;
6907
+ this.initIcons();
6978
6908
  this.once(READY, function() {
6979
6909
  if (playerConfig) {
6980
6910
  if (playerConfig.lang && playerConfig.lang === "en") {
@@ -6985,6 +6915,9 @@ var __publicField = (obj, key, value) => {
6985
6915
  }
6986
6916
  });
6987
6917
  this.on(AUTOPLAY_STARTED, this.onAutoplayStart);
6918
+ if (!playerConfig.autoplay) {
6919
+ this.show();
6920
+ }
6988
6921
  this.on(AUTOPLAY_PREVENTED, function() {
6989
6922
  var className = _this2.config.mode === "auto" ? "auto-hide" : "hide";
6990
6923
  _this2.setAttr("data-state", "play");
@@ -6992,25 +6925,20 @@ var __publicField = (obj, key, value) => {
6992
6925
  _this2.show();
6993
6926
  });
6994
6927
  this.on(PLAY, function() {
6995
- _this2.toggleTo("play");
6928
+ _this2.onPlayPause("play");
6996
6929
  });
6997
6930
  this.on(PAUSE, function() {
6998
- _this2.toggleTo("pause");
6931
+ _this2.onPlayPause("pause");
6999
6932
  });
7000
6933
  this.on(RESET, function() {
7001
6934
  _this2.onPlayerReset();
7002
6935
  });
7003
- }
7004
- }, {
7005
- key: "bindClickEvents",
7006
- value: function bindClickEvents() {
7007
- var _this3 = this;
7008
6936
  this.clickHandler = this.hook("startClick", this.switchPausePlay, {
7009
6937
  pre: function pre(e) {
7010
6938
  e.cancelable && e.preventDefault();
7011
6939
  e.stopPropagation();
7012
- var paused = _this3.player.paused;
7013
- _this3.emitUserAction(e, "switch_play_pause", {
6940
+ var paused = _this2.player.paused;
6941
+ _this2.emitUserAction(e, "switch_play_pause", {
7014
6942
  props: "paused",
7015
6943
  from: paused,
7016
6944
  to: !paused
@@ -7072,17 +7000,17 @@ var __publicField = (obj, key, value) => {
7072
7000
  }, {
7073
7001
  key: "animate",
7074
7002
  value: function animate(endShow) {
7075
- var _this4 = this;
7003
+ var _this3 = this;
7076
7004
  this._animateId = addAnimate("pauseplay", 400, {
7077
7005
  start: function start() {
7078
- util.addClass(_this4.root, "interact");
7079
- _this4.show();
7080
- _this4.switchStatus(true);
7006
+ util.addClass(_this3.root, "interact");
7007
+ _this3.show();
7008
+ _this3.switchStatus(true);
7081
7009
  },
7082
7010
  end: function end() {
7083
- util.removeClass(_this4.root, "interact");
7084
- !endShow && _this4.hide();
7085
- _this4._animateId = null;
7011
+ util.removeClass(_this3.root, "interact");
7012
+ !endShow && _this3.hide();
7013
+ _this3._animateId = null;
7086
7014
  }
7087
7015
  });
7088
7016
  }
@@ -7112,11 +7040,6 @@ var __publicField = (obj, key, value) => {
7112
7040
  }, {
7113
7041
  key: "onPlayPause",
7114
7042
  value: function onPlayPause(status) {
7115
- this.toggleTo(status);
7116
- }
7117
- }, {
7118
- key: "toggleTo",
7119
- value: function toggleTo(status) {
7120
7043
  var config = this.config, player = this.player;
7121
7044
  if (!player || player.state < STATES.RUNNING || !this.autoPlayStart) {
7122
7045
  return;
@@ -8492,7 +8415,7 @@ var __publicField = (obj, key, value) => {
8492
8415
  }
8493
8416
  this.on(DURATION_CHANGE, function() {
8494
8417
  var player2 = _this2.player, config2 = _this2.config;
8495
- if (player2.duration > 0 && player2.duration * 1e3 < config2.moveDuration) {
8418
+ if (player2.duration * 1e3 < config2.moveDuration) {
8496
8419
  config2.moveDuration = player2.duration * 1e3;
8497
8420
  }
8498
8421
  });
@@ -8806,13 +8729,10 @@ var __publicField = (obj, key, value) => {
8806
8729
  }, {
8807
8730
  key: "updateBrightness",
8808
8731
  value: function updateBrightness(percent) {
8809
- var pos = this.pos, config = this.config, xgMask = this.xgMask;
8810
- if (!config.darkness) {
8811
- return;
8812
- }
8813
8732
  if (this.player.rotateDeg) {
8814
8733
  percent = -percent;
8815
8734
  }
8735
+ var pos = this.pos, config = this.config, xgMask = this.xgMask;
8816
8736
  var light = pos.light + 0.8 * percent;
8817
8737
  light = light > config.maxDarkness ? config.maxDarkness : light < 0 ? 0 : light;
8818
8738
  if (xgMask) {
@@ -8873,12 +8793,12 @@ var __publicField = (obj, key, value) => {
8873
8793
  }, {
8874
8794
  key: "disableGesture",
8875
8795
  value: function disableGesture() {
8876
- this.config.disableGesture = true;
8796
+ this.config.disableGesture = false;
8877
8797
  }
8878
8798
  }, {
8879
8799
  key: "enableGesture",
8880
8800
  value: function enableGesture() {
8881
- this.config.disableGesture = false;
8801
+ this.config.disableGesture = true;
8882
8802
  }
8883
8803
  }, {
8884
8804
  key: "destroy",
@@ -9450,55 +9370,28 @@ var __publicField = (obj, key, value) => {
9450
9370
  _inherits(Play2, _IconPlugin);
9451
9371
  var _super = _createSuper(Play2);
9452
9372
  function Play2() {
9453
- var _this;
9454
9373
  _classCallCheck(this, Play2);
9455
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9456
- args[_key] = arguments[_key];
9457
- }
9458
- _this = _super.call.apply(_super, [this].concat(args));
9459
- _defineProperty(_assertThisInitialized(_this), "btnClick", function(e) {
9460
- e.preventDefault();
9461
- e.stopPropagation();
9462
- var _assertThisInitialize = _assertThisInitialized(_this), player = _assertThisInitialize.player;
9463
- _this.emitUserAction(e, "switch_play_pause", {
9464
- prop: "paused",
9465
- from: player.paused,
9466
- to: !player.paused
9467
- });
9468
- if (player.ended) {
9469
- player.replay();
9470
- } else if (player.paused) {
9471
- player.play();
9472
- _this.animate(false);
9473
- } else {
9474
- player.pause();
9475
- _this.animate(true);
9476
- }
9477
- return false;
9478
- });
9479
- return _this;
9374
+ return _super.apply(this, arguments);
9480
9375
  }
9481
9376
  _createClass(Play2, [{
9482
9377
  key: "afterCreate",
9483
9378
  value: function afterCreate() {
9379
+ var _this = this;
9484
9380
  _get(_getPrototypeOf(Play2.prototype), "afterCreate", this).call(this);
9485
- var config = this.config;
9381
+ var player = this.player, config = this.config;
9486
9382
  if (config.disable) {
9487
9383
  return;
9488
9384
  }
9489
9385
  this.initIcons();
9386
+ this.btnClick = this.btnClick.bind(this);
9490
9387
  this.bind(["touchend", "click"], this.btnClick);
9491
- this.listenEvents();
9492
- this.animate(true);
9493
- }
9494
- }, {
9495
- key: "listenEvents",
9496
- value: function listenEvents() {
9497
- var _this2 = this;
9498
- var player = this.player;
9499
- this.on([PLAY, PAUSE, ERROR, EMPTIED], function() {
9500
- _this2.animate(player.paused);
9388
+ this.on([PAUSE, ERROR, EMPTIED], function() {
9389
+ _this.animate(player.paused);
9501
9390
  });
9391
+ this.on(PLAY, function() {
9392
+ _this.animate(player.paused);
9393
+ });
9394
+ this.animate(true);
9502
9395
  }
9503
9396
  }, {
9504
9397
  key: "registerIcons",
@@ -9514,6 +9407,28 @@ var __publicField = (obj, key, value) => {
9514
9407
  }
9515
9408
  };
9516
9409
  }
9410
+ }, {
9411
+ key: "btnClick",
9412
+ value: function btnClick(e) {
9413
+ e.preventDefault();
9414
+ e.stopPropagation();
9415
+ var player = this.player;
9416
+ this.emitUserAction(e, "switch_play_pause", {
9417
+ prop: "paused",
9418
+ from: player.paused,
9419
+ to: !player.paused
9420
+ });
9421
+ if (player.ended) {
9422
+ player.replay();
9423
+ } else if (player.paused) {
9424
+ player.play();
9425
+ this.animate(false);
9426
+ } else {
9427
+ player.pause();
9428
+ this.animate(true);
9429
+ }
9430
+ return false;
9431
+ }
9517
9432
  }, {
9518
9433
  key: "initIcons",
9519
9434
  value: function initIcons() {
@@ -11556,10 +11471,10 @@ var __publicField = (obj, key, value) => {
11556
11471
  const { controls } = this.player;
11557
11472
  const { listType } = this.config;
11558
11473
  if (isActive) {
11559
- listType && MODAL_TYPES.includes(listType) ? controls == null ? void 0 : controls.blur() : controls == null ? void 0 : controls.focus();
11474
+ listType && MODAL_TYPES.includes(listType) ? controls.blur() : controls.focus();
11560
11475
  this.optionsList && this.optionsList.show();
11561
11476
  } else {
11562
- listType && MODAL_TYPES.includes(listType) ? controls == null ? void 0 : controls.focus() : controls == null ? void 0 : controls.focusAwhile();
11477
+ listType && MODAL_TYPES.includes(listType) ? controls.focus() : controls.focusAwhile();
11563
11478
  this.optionsList && this.optionsList.hide();
11564
11479
  }
11565
11480
  this._isActive = isActive;
@@ -13431,28 +13346,33 @@ var __publicField = (obj, key, value) => {
13431
13346
  useCssFullscreen: false
13432
13347
  }
13433
13348
  };
13434
- const transformOption = (options) => {
13435
- const { autoplay: autoplay2, ...rest } = options;
13436
- const xgOptions = rest;
13437
- if (xgOptions.poster) {
13438
- xgOptions.poster = escapeHtml(xgOptions.poster);
13439
- }
13440
- xgOptions.icons = {
13441
- ...DEFAULT_ICONS,
13442
- ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13443
- };
13444
- xgOptions.autoplay = Boolean(autoplay2);
13445
- if (autoplay2 && typeof autoplay2 !== "boolean") {
13446
- xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13447
- xgOptions.videoAttributes = {
13448
- ...xgOptions.videoAttributes ?? {},
13449
- muted: autoplay2 == null ? void 0 : autoplay2.muted
13349
+ const transformOption = (
13350
+ /** {zh}
13351
+ * @param options 更多配置信息。
13352
+ */
13353
+ (options) => {
13354
+ const { autoplay: autoplay2, ...rest } = options;
13355
+ const xgOptions = rest;
13356
+ if (xgOptions.poster) {
13357
+ xgOptions.poster = escapeHtml(xgOptions.poster);
13358
+ }
13359
+ xgOptions.icons = {
13360
+ ...DEFAULT_ICONS,
13361
+ ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13450
13362
  };
13451
- xgOptions.autoplayPlugin = autoplay2;
13363
+ xgOptions.autoplay = Boolean(autoplay2);
13364
+ if (autoplay2 && typeof autoplay2 !== "boolean") {
13365
+ xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13366
+ xgOptions.videoAttributes = {
13367
+ ...xgOptions.videoAttributes ?? {},
13368
+ muted: autoplay2 == null ? void 0 : autoplay2.muted
13369
+ };
13370
+ xgOptions.autoplayPlugin = autoplay2;
13371
+ }
13372
+ delete xgOptions.i18n;
13373
+ return xgOptions;
13452
13374
  }
13453
- delete xgOptions.i18n;
13454
- return xgOptions;
13455
- };
13375
+ );
13456
13376
  class VePlayerBase {
13457
13377
  /** {zh}
13458
13378
  * @hidden
@@ -13472,7 +13392,9 @@ var __publicField = (obj, key, value) => {
13472
13392
  this._sourceManager = options.sourceManager;
13473
13393
  this._preparePlugins = options.preparePlugins;
13474
13394
  this._previousPrepareResult = options.prepareResult;
13475
- this._i18nManager = options.i18nManager ?? new VeI18n({ i18n: options.i18n });
13395
+ this._i18nManager = options.i18nManager ?? new VeI18n({
13396
+ i18n: options.i18n
13397
+ });
13476
13398
  const xgOptions = transformOption({
13477
13399
  ...options,
13478
13400
  ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
@@ -13667,9 +13589,14 @@ var __publicField = (obj, key, value) => {
13667
13589
  /** {zh}
13668
13590
  * 获取播放器版本号
13669
13591
  * @returns
13592
+ * @brief
13593
+ * 获取播放器 SDK 版本号。
13594
+ */
13595
+ /** {en}
13596
+ * @brief Retrieve the player SDK version number.
13670
13597
  */
13671
13598
  get playerVersion() {
13672
- return "2.4.3-rc.0";
13599
+ return "2.4.5-rc.0";
13673
13600
  }
13674
13601
  /** {zh}
13675
13602
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -13817,8 +13744,8 @@ var __publicField = (obj, key, value) => {
13817
13744
  }
13818
13745
  /** {zh}
13819
13746
  * @brief 调用此方法切换拉流地址、线路、清晰度。
13820
- * @param target 目标地址,可以是播放地址,也可以是线路和清晰度
13821
- * @param options 更多配置信息
13747
+ * @param target 目标地址,可以是播放地址,也可以是线路和清晰度。
13748
+ * @param options 更多配置信息。
13822
13749
  */
13823
13750
  /** {en}
13824
13751
  * @brief Switches the pull stream address, playback source, or resolution.
@@ -13829,7 +13756,9 @@ var __publicField = (obj, key, value) => {
13829
13756
  var _a, _b;
13830
13757
  if (typeof target === "string" && this._sourceManager.sources.length === 1 && ((_b = (_a = this._sourceManager.sources) == null ? void 0 : _a[0].definitions) == null ? void 0 : _b.length) === 1) {
13831
13758
  this._sourceManager.updateSources(target);
13832
- await this._switchUrl(target, { seamless: options == null ? void 0 : options.seamless });
13759
+ await this._switchUrl(target, {
13760
+ seamless: options == null ? void 0 : options.seamless
13761
+ });
13833
13762
  return this._sourceManager.definition;
13834
13763
  }
13835
13764
  const targetDefinition = this._sourceManager.find(target, options);
@@ -13856,16 +13785,15 @@ var __publicField = (obj, key, value) => {
13856
13785
  return this._switch(sourceManager.definition);
13857
13786
  }
13858
13787
  // TODO: 等西瓜播放器完善错误码后增加函数重载以提供更好的类型
13859
- /**
13860
13788
  /** {zh}
13861
13789
  * @brief 调用此方法监听指定事件,事件处理函数只执行一次。
13862
13790
  * @param event 表示事件的名称。
13863
13791
  * @param callback 表示事件的回调函数。
13864
13792
  */
13865
13793
  /** {en}
13866
- * @brief Add a one-time listener function for the specified event.
13867
- * @param event The event name.
13868
- * @param callback The callback function for the event.
13794
+ * @brief Call this method to listen for the specified event. The event handler is executed only once.
13795
+ * @param event The name representing the event.
13796
+ * @param callback Callback functions representing events.
13869
13797
  */
13870
13798
  once(event, callback) {
13871
13799
  var _a;
@@ -14016,10 +13944,14 @@ var __publicField = (obj, key, value) => {
14016
13944
  return this._player.blur(data);
14017
13945
  }
14018
13946
  /** {zh}
14019
- * @brief 判断浏览器是否支持播放格式
14020
- * @param type 播放格式
13947
+ * @brief 判断浏览器是否支持播放格式。
13948
+ * @param type 播放格式。
14021
13949
  * @returns
14022
13950
  */
13951
+ /** {en}
13952
+ * @brief Determine whether the browser supports the playback format.
13953
+ * @param type The playback format.
13954
+ */
14023
13955
  canPlayType(type) {
14024
13956
  return this._player.canPlayType(type);
14025
13957
  }
@@ -14091,7 +14023,7 @@ var __publicField = (obj, key, value) => {
14091
14023
  }
14092
14024
  /** {zh}
14093
14025
  * @brief 调用此接口显示指定插件图标。
14094
- * @param pluginNames 插件名称
14026
+ * @param pluginNames 插件名称。
14095
14027
  */
14096
14028
  /** {en}
14097
14029
  * @brief Displays the icon of a specified plugin.
@@ -14112,7 +14044,7 @@ var __publicField = (obj, key, value) => {
14112
14044
  }
14113
14045
  /** {zh}
14114
14046
  * @brief 调用此接口隐藏指定插件图标。
14115
- * @param pluginNames 插件名称
14047
+ * @param pluginNames 插件名称。
14116
14048
  */
14117
14049
  /** {en}
14118
14050
  * @brief Hides the icon of a specified plugin.
@@ -14184,7 +14116,14 @@ var __publicField = (obj, key, value) => {
14184
14116
  this._player.once("canplay", () => {
14185
14117
  this._sourceManager.resetFallback();
14186
14118
  });
14187
- this.emit(Events.FALLBACK, { from: { url: preUrl }, to: { url } });
14119
+ this.emit(Events.FALLBACK, {
14120
+ from: {
14121
+ url: preUrl
14122
+ },
14123
+ to: {
14124
+ url
14125
+ }
14126
+ });
14188
14127
  this._switchUrl(url);
14189
14128
  }
14190
14129
  // eslint-disable-next-line @typescript-eslint/no-explicit-any