@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.
@@ -1307,7 +1307,7 @@ var VERSION_REG = {
1307
1307
  android: /(Android)\s([\d.]+)/,
1308
1308
  ios: /(Version)\/([\d.]+)/
1309
1309
  };
1310
- 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"];
1310
+ 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"];
1311
1311
  var sniffer = {
1312
1312
  get device() {
1313
1313
  var r = sniffer.os;
@@ -1452,7 +1452,7 @@ var sniffer = {
1452
1452
  }
1453
1453
  }
1454
1454
  };
1455
- var version = "3.0.20-rc.6";
1455
+ var version = "3.0.19-rc.0";
1456
1456
  var ERROR_TYPE_MAP = {
1457
1457
  1: "media",
1458
1458
  2: "media",
@@ -2422,7 +2422,8 @@ function hook(hookName, handler) {
2422
2422
  }
2423
2423
  if (this.__hooks && this.__hooks[hookName]) {
2424
2424
  try {
2425
- var preRet = runHooks(this, hookName, handler);
2425
+ var _this$__hooks$hookNam;
2426
+ var preRet = (_this$__hooks$hookNam = this.__hooks[hookName]).call.apply(_this$__hooks$hookNam, [this, this].concat(Array.prototype.slice.call(arguments)));
2426
2427
  if (preRet) {
2427
2428
  if (preRet.then) {
2428
2429
  preRet.then(function(isContinue) {
@@ -2447,19 +2448,6 @@ function hook(hookName, handler) {
2447
2448
  }
2448
2449
  }.bind(this);
2449
2450
  }
2450
- function findHookIndex(hookName, handler) {
2451
- var __hooks = this.__hooks;
2452
- if (!__hooks || !Array.isArray(__hooks[hookName])) {
2453
- return -1;
2454
- }
2455
- var hookHandlers = __hooks[hookName];
2456
- for (var i = 0; i < hookHandlers.length; i++) {
2457
- if (hookHandlers[i] === handler) {
2458
- return i;
2459
- }
2460
- }
2461
- return -1;
2462
- }
2463
2451
  function useHooks(hookName, handler) {
2464
2452
  var __hooks = this.__hooks;
2465
2453
  if (!__hooks) {
@@ -2469,12 +2457,7 @@ function useHooks(hookName, handler) {
2469
2457
  console.warn("has no supported hook which name [".concat(hookName, "]"));
2470
2458
  return false;
2471
2459
  }
2472
- if (!Array.isArray(__hooks[hookName])) {
2473
- __hooks[hookName] = [];
2474
- }
2475
- if (findHookIndex.call(this, hookName, handler) === -1) {
2476
- __hooks[hookName].push(handler);
2477
- }
2460
+ __hooks && (__hooks[hookName] = handler);
2478
2461
  return true;
2479
2462
  }
2480
2463
  function removeHooks(hookName, handler) {
@@ -2482,13 +2465,6 @@ function removeHooks(hookName, handler) {
2482
2465
  if (!__hooks) {
2483
2466
  return;
2484
2467
  }
2485
- if (Array.isArray(__hooks[hookName])) {
2486
- var hooks = __hooks[hookName];
2487
- var index = findHookIndex.call(this, hookName, handler);
2488
- if (index !== -1) {
2489
- hooks.splice(index, 1);
2490
- }
2491
- }
2492
2468
  delete __hooks[hookName];
2493
2469
  }
2494
2470
  function usePluginHooks(pluginName) {
@@ -2536,30 +2512,18 @@ function runHooks(obj, hookName, handler) {
2536
2512
  for (var _len5 = arguments.length, args = new Array(_len5 > 3 ? _len5 - 3 : 0), _key5 = 3; _key5 < _len5; _key5++) {
2537
2513
  args[_key5 - 3] = arguments[_key5];
2538
2514
  }
2539
- if (obj.__hooks && Array.isArray(obj.__hooks[hookName])) {
2540
- var hooks = obj.__hooks[hookName];
2541
- var index = -1;
2542
- var runHooksRecursive = function runHooksRecursive2(obj2, hookName2, handler2) {
2543
- for (var _len6 = arguments.length, args2 = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) {
2544
- args2[_key6 - 3] = arguments[_key6];
2545
- }
2546
- index++;
2547
- if (hooks.length === 0 || index === hooks.length) {
2548
- return handler2.call.apply(handler2, [obj2, obj2].concat(args2));
2549
- }
2550
- var hook2 = hooks[index];
2551
- var ret = hook2.call.apply(hook2, [obj2, obj2].concat(args2));
2552
- if (ret && ret.then) {
2553
- return ret.then(function(data) {
2554
- return data === false ? null : runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
2555
- }).catch(function(e) {
2556
- console.warn("[runHooks]".concat(hookName2, " reject"), e.message);
2557
- });
2558
- } else if (ret !== false) {
2559
- return runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
2560
- }
2561
- };
2562
- return runHooksRecursive.apply(void 0, [obj, hookName, handler].concat(args));
2515
+ if (obj.__hooks && obj.__hooks[hookName]) {
2516
+ var _obj$__hooks$hookName;
2517
+ var ret = (_obj$__hooks$hookName = obj.__hooks[hookName]).call.apply(_obj$__hooks$hookName, [obj, obj].concat(args));
2518
+ if (ret && ret.then) {
2519
+ ret.then(function(data) {
2520
+ return data === false ? null : handler.call.apply(handler, [obj, obj].concat(args));
2521
+ }).catch(function(e) {
2522
+ console.warn("[runHooks]".concat(hookName, " reject"), e.message);
2523
+ });
2524
+ } else if (ret !== false) {
2525
+ return handler.call.apply(handler, [obj, obj].concat(args));
2526
+ }
2563
2527
  } else {
2564
2528
  return handler.call.apply(handler, [obj, obj].concat(args));
2565
2529
  }
@@ -2803,18 +2767,6 @@ var BasePlugin = /* @__PURE__ */ function() {
2803
2767
  }
2804
2768
  }
2805
2769
  }
2806
- }, {
2807
- key: "defineMethod",
2808
- value: function defineMethod(Obj, map) {
2809
- for (var key in map) {
2810
- if (Object.prototype.hasOwnProperty.call(map, key) && typeof map[key] === "function") {
2811
- Object.defineProperty(Obj, key, {
2812
- configurable: true,
2813
- value: map[key]
2814
- });
2815
- }
2816
- }
2817
- }
2818
2770
  }, {
2819
2771
  key: "defaultConfig",
2820
2772
  get: function get() {
@@ -3460,7 +3412,7 @@ var ResizeObserver = /* @__PURE__ */ function() {
3460
3412
  if (!this.observer) {
3461
3413
  return;
3462
3414
  }
3463
- this.observer.observe(target);
3415
+ this.observer && this.observer.observe(target);
3464
3416
  var _pid = target.getAttribute(PLATER_ID);
3465
3417
  var __handlers = this.__handlers;
3466
3418
  var index = -1;
@@ -3489,17 +3441,16 @@ var ResizeObserver = /* @__PURE__ */ function() {
3489
3441
  }
3490
3442
  });
3491
3443
  try {
3492
- var _this$observer;
3493
- (_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.unobserve(target);
3444
+ this.observer && this.observer.unobserve(target);
3494
3445
  } catch (e) {
3495
3446
  }
3447
+ this.observer && this.observer.unobserve(target);
3496
3448
  i > -1 && this.__handlers.splice(i, 1);
3497
3449
  }
3498
3450
  }, {
3499
3451
  key: "destroyObserver",
3500
3452
  value: function destroyObserver() {
3501
- var _this$observer2;
3502
- (_this$observer2 = this.observer) === null || _this$observer2 === void 0 ? void 0 : _this$observer2.disconnect();
3453
+ this.observer && this.observer.disconnect();
3503
3454
  this.observer = null;
3504
3455
  this.__handlers = null;
3505
3456
  }
@@ -3531,8 +3482,7 @@ function addObserver(target, handler) {
3531
3482
  return resizeObserver;
3532
3483
  }
3533
3484
  function unObserver(target, handler) {
3534
- var _resizeObserver;
3535
- (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.unObserver(target, handler);
3485
+ resizeObserver.unObserver(target, handler);
3536
3486
  }
3537
3487
  var pluginsManager = {
3538
3488
  pluginGroup: {},
@@ -4530,7 +4480,10 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
4530
4480
  }
4531
4481
  var _this$config = _this.config, autoplay2 = _this$config.autoplay, defaultPlaybackRate = _this$config.defaultPlaybackRate;
4532
4482
  XG_DEBUG.logInfo("player", "canPlayFunc, startTime", _this.__startTime);
4533
- _this._seekToStartTime();
4483
+ if (_this.__startTime > 0 && _this.duration > 0) {
4484
+ _this.currentTime = _this.__startTime > _this.duration ? _this.duration : _this.__startTime;
4485
+ _this.__startTime = -1;
4486
+ }
4534
4487
  _this.playbackRate = defaultPlaybackRate;
4535
4488
  (autoplay2 || _this._useAutoplay) && _this.mediaPlay();
4536
4489
  _this.off(CANPLAY, _this.canPlayFunc);
@@ -4620,7 +4573,6 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
4620
4573
  _this.waitTimer = null;
4621
4574
  _this.handleSource = true;
4622
4575
  _this._state = STATES.INITIAL;
4623
- _this.isAd = false;
4624
4576
  _this.isError = false;
4625
4577
  _this._hasStart = false;
4626
4578
  _this.isSeeking = false;
@@ -5005,8 +4957,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5005
4957
  _pConfig.position && (options.position = _pConfig.position);
5006
4958
  var position = options.position ? options.position : options.config && options.config.position || PLUFGIN.defaultConfig && PLUFGIN.defaultConfig.position;
5007
4959
  if (!options.root && typeof position === "string" && position.indexOf("controls") > -1) {
5008
- var _this$controls;
5009
- return (_this$controls = this.controls) === null || _this$controls === void 0 ? void 0 : _this$controls.registerPlugin(PLUFGIN, options, PLUFGIN.pluginName);
4960
+ return this.controls && this.controls.registerPlugin(PLUFGIN, options, PLUFGIN.pluginName);
5010
4961
  }
5011
4962
  if (!options.root) {
5012
4963
  options.root = this._getRootByPosition(position);
@@ -5154,7 +5105,10 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5154
5105
  reject(e);
5155
5106
  };
5156
5107
  var _canplay = function _canplay2() {
5157
- _this9._seekToStartTime();
5108
+ if (_this9.duration > 0 && _this9.__startTime > 0) {
5109
+ _this9.currentTime = _this9.__startTime;
5110
+ _this9.__startTime = -1;
5111
+ }
5158
5112
  if (isPaused) {
5159
5113
  _this9.pause();
5160
5114
  }
@@ -5775,17 +5729,11 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5775
5729
  }, {
5776
5730
  key: "onLoadeddata",
5777
5731
  value: function onLoadeddata() {
5778
- var _this22 = this;
5779
5732
  this.isError = false;
5780
5733
  this.isSeeking = false;
5781
- if (this.__startTime > 0) {
5782
- if (this.duration > 0) {
5783
- this._seekToStartTime();
5784
- } else {
5785
- this.once(DURATION_CHANGE, function() {
5786
- _this22._seekToStartTime();
5787
- });
5788
- }
5734
+ if (this.__startTime > 0 && this.duration > 0) {
5735
+ this.currentTime = this.__startTime;
5736
+ this.__startTime = -1;
5789
5737
  }
5790
5738
  }
5791
5739
  }, {
@@ -5854,27 +5802,27 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5854
5802
  }, {
5855
5803
  key: "onWaiting",
5856
5804
  value: function onWaiting() {
5857
- var _this23 = this;
5805
+ var _this22 = this;
5858
5806
  if (this.waitTimer) {
5859
5807
  util.clearTimeout(this, this.waitTimer);
5860
5808
  }
5861
5809
  this.updateAcc("waiting");
5862
5810
  this.waitTimer = util.setTimeout(this, function() {
5863
- _this23.addClass(STATE_CLASS.LOADING);
5864
- _this23.emit(LOADING);
5865
- util.clearTimeout(_this23, _this23.waitTimer);
5866
- _this23.waitTimer = null;
5811
+ _this22.addClass(STATE_CLASS.LOADING);
5812
+ _this22.emit(LOADING);
5813
+ util.clearTimeout(_this22, _this22.waitTimer);
5814
+ _this22.waitTimer = null;
5867
5815
  }, this.config.minWaitDelay);
5868
5816
  }
5869
5817
  }, {
5870
5818
  key: "onPlaying",
5871
5819
  value: function onPlaying() {
5872
- var _this24 = this;
5820
+ var _this23 = this;
5873
5821
  this.isError = false;
5874
5822
  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;
5875
5823
  var clsList = [NO_START, PAUSED, ENDED2, ERROR2, REPLAY2, LOADING2];
5876
5824
  clsList.forEach(function(cls) {
5877
- _this24.removeClass(cls);
5825
+ _this23.removeClass(cls);
5878
5826
  });
5879
5827
  if (!this._accPlayed.t && !this.paused && !this.ended) {
5880
5828
  this._accPlayed.t = (/* @__PURE__ */ new Date()).getTime();
@@ -6035,14 +5983,14 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6035
5983
  }, {
6036
5984
  key: "setConfig",
6037
5985
  value: function setConfig(config) {
6038
- var _this25 = this;
5986
+ var _this24 = this;
6039
5987
  if (!config) {
6040
5988
  return;
6041
5989
  }
6042
5990
  Object.keys(config).map(function(key) {
6043
5991
  if (key !== "plugins") {
6044
- _this25.config[key] = config[key];
6045
- var plugin = _this25.plugins[key.toLowerCase()];
5992
+ _this24.config[key] = config[key];
5993
+ var plugin = _this24.plugins[key.toLowerCase()];
6046
5994
  if (plugin && util.typeOf(plugin.setConfig) === "Function") {
6047
5995
  plugin.setConfig(config[key]);
6048
5996
  }
@@ -6052,20 +6000,20 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6052
6000
  }, {
6053
6001
  key: "playNext",
6054
6002
  value: function playNext(config) {
6055
- var _this26 = this;
6003
+ var _this25 = this;
6056
6004
  this.resetState();
6057
6005
  this.setConfig(config);
6058
6006
  this._currentTime = 0;
6059
6007
  this._duration = 0;
6060
6008
  runHooks(this, "playnext", function() {
6061
- _this26.start();
6062
- _this26.emit(PLAYNEXT, config);
6009
+ _this25.start();
6010
+ _this25.emit(PLAYNEXT, config);
6063
6011
  });
6064
6012
  }
6065
6013
  }, {
6066
6014
  key: "resize",
6067
6015
  value: function resize() {
6068
- var _this27 = this;
6016
+ var _this26 = this;
6069
6017
  if (!this.media) {
6070
6018
  return;
6071
6019
  }
@@ -6105,7 +6053,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6105
6053
  }
6106
6054
  if (!this.fullscreen && !this.cssfullscreen) {
6107
6055
  Object.keys(_style).forEach(function(key) {
6108
- _this27.root.style[key] = _style[key];
6056
+ _this26.root.style[key] = _style[key];
6109
6057
  });
6110
6058
  }
6111
6059
  if (videoFillMode === "fillHeight" && fit < videoFit || videoFillMode === "fillWidth" && fit > videoFit) {
@@ -6147,14 +6095,6 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6147
6095
  url
6148
6096
  };
6149
6097
  }
6150
- }, {
6151
- key: "_seekToStartTime",
6152
- value: function _seekToStartTime() {
6153
- if (this.__startTime > 0 && this.duration > 0) {
6154
- this.currentTime = this.__startTime > this.duration ? this.duration : this.__startTime;
6155
- this.__startTime = -1;
6156
- }
6157
- }
6158
6098
  }, {
6159
6099
  key: "state",
6160
6100
  get: function get() {
@@ -6205,15 +6145,15 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6205
6145
  return this.config.definition.list || [];
6206
6146
  },
6207
6147
  set: function set(list) {
6208
- var _this28 = this;
6148
+ var _this27 = this;
6209
6149
  var definition = this.config.definition;
6210
6150
  var curDef = null;
6211
6151
  var targetDef = null;
6212
6152
  definition.list = list;
6213
6153
  this.emit("resourceReady", list);
6214
6154
  list.forEach(function(item) {
6215
- var _this28$curDefinition;
6216
- if (((_this28$curDefinition = _this28.curDefinition) === null || _this28$curDefinition === void 0 ? void 0 : _this28$curDefinition.definition) === item.definition) {
6155
+ var _this27$curDefinition;
6156
+ if (((_this27$curDefinition = _this27.curDefinition) === null || _this27$curDefinition === void 0 ? void 0 : _this27$curDefinition.definition) === item.definition) {
6217
6157
  curDef = item;
6218
6158
  }
6219
6159
  if (definition.defaultDefinition === item.definition) {
@@ -6709,11 +6649,11 @@ class VeError extends Error {
6709
6649
  } : error2;
6710
6650
  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"));
6711
6651
  super(message);
6712
- /**
6652
+ /** {zh}
6713
6653
  * @brief 错误码。
6714
6654
  */
6715
6655
  /** {en}
6716
- * @brief The error code.
6656
+ * @brief Error code.
6717
6657
  */
6718
6658
  __publicField(this, "errorCode");
6719
6659
  /** {zh}
@@ -6950,7 +6890,7 @@ var Start = /* @__PURE__ */ function(_Plugin) {
6950
6890
  var className = _this.config.mode === "auto" ? "auto-hide" : "hide";
6951
6891
  util.addClass(_this.root, className);
6952
6892
  _this.autoPlayStart = true;
6953
- _this.toggleTo("play");
6893
+ _this.onPlayPause("play");
6954
6894
  });
6955
6895
  _this.autoPlayStart = false;
6956
6896
  return _this;
@@ -6958,19 +6898,9 @@ var Start = /* @__PURE__ */ function(_Plugin) {
6958
6898
  _createClass(Start2, [{
6959
6899
  key: "afterCreate",
6960
6900
  value: function afterCreate() {
6961
- var playerConfig = this.playerConfig;
6962
- this.initIcons();
6963
- this.listenEvents();
6964
- this.bindClickEvents();
6965
- if (!playerConfig.autoplay) {
6966
- this.show();
6967
- }
6968
- }
6969
- }, {
6970
- key: "listenEvents",
6971
- value: function listenEvents() {
6972
6901
  var _this2 = this;
6973
6902
  var player = this.player, playerConfig = this.playerConfig;
6903
+ this.initIcons();
6974
6904
  this.once(READY, function() {
6975
6905
  if (playerConfig) {
6976
6906
  if (playerConfig.lang && playerConfig.lang === "en") {
@@ -6981,6 +6911,9 @@ var Start = /* @__PURE__ */ function(_Plugin) {
6981
6911
  }
6982
6912
  });
6983
6913
  this.on(AUTOPLAY_STARTED, this.onAutoplayStart);
6914
+ if (!playerConfig.autoplay) {
6915
+ this.show();
6916
+ }
6984
6917
  this.on(AUTOPLAY_PREVENTED, function() {
6985
6918
  var className = _this2.config.mode === "auto" ? "auto-hide" : "hide";
6986
6919
  _this2.setAttr("data-state", "play");
@@ -6988,25 +6921,20 @@ var Start = /* @__PURE__ */ function(_Plugin) {
6988
6921
  _this2.show();
6989
6922
  });
6990
6923
  this.on(PLAY, function() {
6991
- _this2.toggleTo("play");
6924
+ _this2.onPlayPause("play");
6992
6925
  });
6993
6926
  this.on(PAUSE, function() {
6994
- _this2.toggleTo("pause");
6927
+ _this2.onPlayPause("pause");
6995
6928
  });
6996
6929
  this.on(RESET, function() {
6997
6930
  _this2.onPlayerReset();
6998
6931
  });
6999
- }
7000
- }, {
7001
- key: "bindClickEvents",
7002
- value: function bindClickEvents() {
7003
- var _this3 = this;
7004
6932
  this.clickHandler = this.hook("startClick", this.switchPausePlay, {
7005
6933
  pre: function pre(e) {
7006
6934
  e.cancelable && e.preventDefault();
7007
6935
  e.stopPropagation();
7008
- var paused = _this3.player.paused;
7009
- _this3.emitUserAction(e, "switch_play_pause", {
6936
+ var paused = _this2.player.paused;
6937
+ _this2.emitUserAction(e, "switch_play_pause", {
7010
6938
  props: "paused",
7011
6939
  from: paused,
7012
6940
  to: !paused
@@ -7068,17 +6996,17 @@ var Start = /* @__PURE__ */ function(_Plugin) {
7068
6996
  }, {
7069
6997
  key: "animate",
7070
6998
  value: function animate(endShow) {
7071
- var _this4 = this;
6999
+ var _this3 = this;
7072
7000
  this._animateId = addAnimate("pauseplay", 400, {
7073
7001
  start: function start() {
7074
- util.addClass(_this4.root, "interact");
7075
- _this4.show();
7076
- _this4.switchStatus(true);
7002
+ util.addClass(_this3.root, "interact");
7003
+ _this3.show();
7004
+ _this3.switchStatus(true);
7077
7005
  },
7078
7006
  end: function end() {
7079
- util.removeClass(_this4.root, "interact");
7080
- !endShow && _this4.hide();
7081
- _this4._animateId = null;
7007
+ util.removeClass(_this3.root, "interact");
7008
+ !endShow && _this3.hide();
7009
+ _this3._animateId = null;
7082
7010
  }
7083
7011
  });
7084
7012
  }
@@ -7108,11 +7036,6 @@ var Start = /* @__PURE__ */ function(_Plugin) {
7108
7036
  }, {
7109
7037
  key: "onPlayPause",
7110
7038
  value: function onPlayPause(status) {
7111
- this.toggleTo(status);
7112
- }
7113
- }, {
7114
- key: "toggleTo",
7115
- value: function toggleTo(status) {
7116
7039
  var config = this.config, player = this.player;
7117
7040
  if (!player || player.state < STATES.RUNNING || !this.autoPlayStart) {
7118
7041
  return;
@@ -8488,7 +8411,7 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8488
8411
  }
8489
8412
  this.on(DURATION_CHANGE, function() {
8490
8413
  var player2 = _this2.player, config2 = _this2.config;
8491
- if (player2.duration > 0 && player2.duration * 1e3 < config2.moveDuration) {
8414
+ if (player2.duration * 1e3 < config2.moveDuration) {
8492
8415
  config2.moveDuration = player2.duration * 1e3;
8493
8416
  }
8494
8417
  });
@@ -8802,13 +8725,10 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8802
8725
  }, {
8803
8726
  key: "updateBrightness",
8804
8727
  value: function updateBrightness(percent) {
8805
- var pos = this.pos, config = this.config, xgMask = this.xgMask;
8806
- if (!config.darkness) {
8807
- return;
8808
- }
8809
8728
  if (this.player.rotateDeg) {
8810
8729
  percent = -percent;
8811
8730
  }
8731
+ var pos = this.pos, config = this.config, xgMask = this.xgMask;
8812
8732
  var light = pos.light + 0.8 * percent;
8813
8733
  light = light > config.maxDarkness ? config.maxDarkness : light < 0 ? 0 : light;
8814
8734
  if (xgMask) {
@@ -8869,12 +8789,12 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8869
8789
  }, {
8870
8790
  key: "disableGesture",
8871
8791
  value: function disableGesture() {
8872
- this.config.disableGesture = true;
8792
+ this.config.disableGesture = false;
8873
8793
  }
8874
8794
  }, {
8875
8795
  key: "enableGesture",
8876
8796
  value: function enableGesture() {
8877
- this.config.disableGesture = false;
8797
+ this.config.disableGesture = true;
8878
8798
  }
8879
8799
  }, {
8880
8800
  key: "destroy",
@@ -9446,55 +9366,28 @@ var Play$1 = /* @__PURE__ */ function(_IconPlugin) {
9446
9366
  _inherits(Play2, _IconPlugin);
9447
9367
  var _super = _createSuper(Play2);
9448
9368
  function Play2() {
9449
- var _this;
9450
9369
  _classCallCheck(this, Play2);
9451
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9452
- args[_key] = arguments[_key];
9453
- }
9454
- _this = _super.call.apply(_super, [this].concat(args));
9455
- _defineProperty(_assertThisInitialized(_this), "btnClick", function(e) {
9456
- e.preventDefault();
9457
- e.stopPropagation();
9458
- var _assertThisInitialize = _assertThisInitialized(_this), player = _assertThisInitialize.player;
9459
- _this.emitUserAction(e, "switch_play_pause", {
9460
- prop: "paused",
9461
- from: player.paused,
9462
- to: !player.paused
9463
- });
9464
- if (player.ended) {
9465
- player.replay();
9466
- } else if (player.paused) {
9467
- player.play();
9468
- _this.animate(false);
9469
- } else {
9470
- player.pause();
9471
- _this.animate(true);
9472
- }
9473
- return false;
9474
- });
9475
- return _this;
9370
+ return _super.apply(this, arguments);
9476
9371
  }
9477
9372
  _createClass(Play2, [{
9478
9373
  key: "afterCreate",
9479
9374
  value: function afterCreate() {
9375
+ var _this = this;
9480
9376
  _get(_getPrototypeOf(Play2.prototype), "afterCreate", this).call(this);
9481
- var config = this.config;
9377
+ var player = this.player, config = this.config;
9482
9378
  if (config.disable) {
9483
9379
  return;
9484
9380
  }
9485
9381
  this.initIcons();
9382
+ this.btnClick = this.btnClick.bind(this);
9486
9383
  this.bind(["touchend", "click"], this.btnClick);
9487
- this.listenEvents();
9488
- this.animate(true);
9489
- }
9490
- }, {
9491
- key: "listenEvents",
9492
- value: function listenEvents() {
9493
- var _this2 = this;
9494
- var player = this.player;
9495
- this.on([PLAY, PAUSE, ERROR, EMPTIED], function() {
9496
- _this2.animate(player.paused);
9384
+ this.on([PAUSE, ERROR, EMPTIED], function() {
9385
+ _this.animate(player.paused);
9497
9386
  });
9387
+ this.on(PLAY, function() {
9388
+ _this.animate(player.paused);
9389
+ });
9390
+ this.animate(true);
9498
9391
  }
9499
9392
  }, {
9500
9393
  key: "registerIcons",
@@ -9510,6 +9403,28 @@ var Play$1 = /* @__PURE__ */ function(_IconPlugin) {
9510
9403
  }
9511
9404
  };
9512
9405
  }
9406
+ }, {
9407
+ key: "btnClick",
9408
+ value: function btnClick(e) {
9409
+ e.preventDefault();
9410
+ e.stopPropagation();
9411
+ var player = this.player;
9412
+ this.emitUserAction(e, "switch_play_pause", {
9413
+ prop: "paused",
9414
+ from: player.paused,
9415
+ to: !player.paused
9416
+ });
9417
+ if (player.ended) {
9418
+ player.replay();
9419
+ } else if (player.paused) {
9420
+ player.play();
9421
+ this.animate(false);
9422
+ } else {
9423
+ player.pause();
9424
+ this.animate(true);
9425
+ }
9426
+ return false;
9427
+ }
9513
9428
  }, {
9514
9429
  key: "initIcons",
9515
9430
  value: function initIcons() {
@@ -11552,10 +11467,10 @@ class OptionsIcon extends Plugin {
11552
11467
  const { controls } = this.player;
11553
11468
  const { listType } = this.config;
11554
11469
  if (isActive) {
11555
- listType && MODAL_TYPES.includes(listType) ? controls == null ? void 0 : controls.blur() : controls == null ? void 0 : controls.focus();
11470
+ listType && MODAL_TYPES.includes(listType) ? controls.blur() : controls.focus();
11556
11471
  this.optionsList && this.optionsList.show();
11557
11472
  } else {
11558
- listType && MODAL_TYPES.includes(listType) ? controls == null ? void 0 : controls.focus() : controls == null ? void 0 : controls.focusAwhile();
11473
+ listType && MODAL_TYPES.includes(listType) ? controls.focus() : controls.focusAwhile();
11559
11474
  this.optionsList && this.optionsList.hide();
11560
11475
  }
11561
11476
  this._isActive = isActive;
@@ -13427,28 +13342,33 @@ const DEFAULT_OPTIONS = {
13427
13342
  useCssFullscreen: false
13428
13343
  }
13429
13344
  };
13430
- const transformOption = (options) => {
13431
- const { autoplay: autoplay2, ...rest } = options;
13432
- const xgOptions = rest;
13433
- if (xgOptions.poster) {
13434
- xgOptions.poster = escapeHtml(xgOptions.poster);
13435
- }
13436
- xgOptions.icons = {
13437
- ...DEFAULT_ICONS,
13438
- ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13439
- };
13440
- xgOptions.autoplay = Boolean(autoplay2);
13441
- if (autoplay2 && typeof autoplay2 !== "boolean") {
13442
- xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13443
- xgOptions.videoAttributes = {
13444
- ...xgOptions.videoAttributes ?? {},
13445
- muted: autoplay2 == null ? void 0 : autoplay2.muted
13345
+ const transformOption = (
13346
+ /** {zh}
13347
+ * @param options 更多配置信息。
13348
+ */
13349
+ (options) => {
13350
+ const { autoplay: autoplay2, ...rest } = options;
13351
+ const xgOptions = rest;
13352
+ if (xgOptions.poster) {
13353
+ xgOptions.poster = escapeHtml(xgOptions.poster);
13354
+ }
13355
+ xgOptions.icons = {
13356
+ ...DEFAULT_ICONS,
13357
+ ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13446
13358
  };
13447
- xgOptions.autoplayPlugin = autoplay2;
13359
+ xgOptions.autoplay = Boolean(autoplay2);
13360
+ if (autoplay2 && typeof autoplay2 !== "boolean") {
13361
+ xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13362
+ xgOptions.videoAttributes = {
13363
+ ...xgOptions.videoAttributes ?? {},
13364
+ muted: autoplay2 == null ? void 0 : autoplay2.muted
13365
+ };
13366
+ xgOptions.autoplayPlugin = autoplay2;
13367
+ }
13368
+ delete xgOptions.i18n;
13369
+ return xgOptions;
13448
13370
  }
13449
- delete xgOptions.i18n;
13450
- return xgOptions;
13451
- };
13371
+ );
13452
13372
  class VePlayerBase {
13453
13373
  /** {zh}
13454
13374
  * @hidden
@@ -13468,7 +13388,9 @@ class VePlayerBase {
13468
13388
  this._sourceManager = options.sourceManager;
13469
13389
  this._preparePlugins = options.preparePlugins;
13470
13390
  this._previousPrepareResult = options.prepareResult;
13471
- this._i18nManager = options.i18nManager ?? new VeI18n({ i18n: options.i18n });
13391
+ this._i18nManager = options.i18nManager ?? new VeI18n({
13392
+ i18n: options.i18n
13393
+ });
13472
13394
  const xgOptions = transformOption({
13473
13395
  ...options,
13474
13396
  ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
@@ -13663,9 +13585,14 @@ class VePlayerBase {
13663
13585
  /** {zh}
13664
13586
  * 获取播放器版本号
13665
13587
  * @returns
13588
+ * @brief
13589
+ * 获取播放器 SDK 版本号。
13590
+ */
13591
+ /** {en}
13592
+ * @brief Retrieve the player SDK version number.
13666
13593
  */
13667
13594
  get playerVersion() {
13668
- return "2.4.3-rc.0";
13595
+ return "2.4.5-rc.0";
13669
13596
  }
13670
13597
  /** {zh}
13671
13598
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -13813,8 +13740,8 @@ class VePlayerBase {
13813
13740
  }
13814
13741
  /** {zh}
13815
13742
  * @brief 调用此方法切换拉流地址、线路、清晰度。
13816
- * @param target 目标地址,可以是播放地址,也可以是线路和清晰度
13817
- * @param options 更多配置信息
13743
+ * @param target 目标地址,可以是播放地址,也可以是线路和清晰度。
13744
+ * @param options 更多配置信息。
13818
13745
  */
13819
13746
  /** {en}
13820
13747
  * @brief Switches the pull stream address, playback source, or resolution.
@@ -13825,7 +13752,9 @@ class VePlayerBase {
13825
13752
  var _a, _b;
13826
13753
  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) {
13827
13754
  this._sourceManager.updateSources(target);
13828
- await this._switchUrl(target, { seamless: options == null ? void 0 : options.seamless });
13755
+ await this._switchUrl(target, {
13756
+ seamless: options == null ? void 0 : options.seamless
13757
+ });
13829
13758
  return this._sourceManager.definition;
13830
13759
  }
13831
13760
  const targetDefinition = this._sourceManager.find(target, options);
@@ -13852,16 +13781,15 @@ class VePlayerBase {
13852
13781
  return this._switch(sourceManager.definition);
13853
13782
  }
13854
13783
  // TODO: 等西瓜播放器完善错误码后增加函数重载以提供更好的类型
13855
- /**
13856
13784
  /** {zh}
13857
13785
  * @brief 调用此方法监听指定事件,事件处理函数只执行一次。
13858
13786
  * @param event 表示事件的名称。
13859
13787
  * @param callback 表示事件的回调函数。
13860
13788
  */
13861
13789
  /** {en}
13862
- * @brief Add a one-time listener function for the specified event.
13863
- * @param event The event name.
13864
- * @param callback The callback function for the event.
13790
+ * @brief Call this method to listen for the specified event. The event handler is executed only once.
13791
+ * @param event The name representing the event.
13792
+ * @param callback Callback functions representing events.
13865
13793
  */
13866
13794
  once(event, callback) {
13867
13795
  var _a;
@@ -14012,10 +13940,14 @@ class VePlayerBase {
14012
13940
  return this._player.blur(data);
14013
13941
  }
14014
13942
  /** {zh}
14015
- * @brief 判断浏览器是否支持播放格式
14016
- * @param type 播放格式
13943
+ * @brief 判断浏览器是否支持播放格式。
13944
+ * @param type 播放格式。
14017
13945
  * @returns
14018
13946
  */
13947
+ /** {en}
13948
+ * @brief Determine whether the browser supports the playback format.
13949
+ * @param type The playback format.
13950
+ */
14019
13951
  canPlayType(type) {
14020
13952
  return this._player.canPlayType(type);
14021
13953
  }
@@ -14087,7 +14019,7 @@ class VePlayerBase {
14087
14019
  }
14088
14020
  /** {zh}
14089
14021
  * @brief 调用此接口显示指定插件图标。
14090
- * @param pluginNames 插件名称
14022
+ * @param pluginNames 插件名称。
14091
14023
  */
14092
14024
  /** {en}
14093
14025
  * @brief Displays the icon of a specified plugin.
@@ -14108,7 +14040,7 @@ class VePlayerBase {
14108
14040
  }
14109
14041
  /** {zh}
14110
14042
  * @brief 调用此接口隐藏指定插件图标。
14111
- * @param pluginNames 插件名称
14043
+ * @param pluginNames 插件名称。
14112
14044
  */
14113
14045
  /** {en}
14114
14046
  * @brief Hides the icon of a specified plugin.
@@ -14180,7 +14112,14 @@ class VePlayerBase {
14180
14112
  this._player.once("canplay", () => {
14181
14113
  this._sourceManager.resetFallback();
14182
14114
  });
14183
- this.emit(Events.FALLBACK, { from: { url: preUrl }, to: { url } });
14115
+ this.emit(Events.FALLBACK, {
14116
+ from: {
14117
+ url: preUrl
14118
+ },
14119
+ to: {
14120
+ url
14121
+ }
14122
+ });
14184
14123
  this._switchUrl(url);
14185
14124
  }
14186
14125
  // eslint-disable-next-line @typescript-eslint/no-explicit-any