@volcengine/veplayer 2.4.3-rc.1 → 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.
@@ -1316,7 +1316,7 @@ var __publicField = (obj, key, value) => {
1316
1316
  android: /(Android)\s([\d.]+)/,
1317
1317
  ios: /(Version)\/([\d.]+)/
1318
1318
  };
1319
- 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"];
1319
+ 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"];
1320
1320
  var sniffer$1 = {
1321
1321
  get device() {
1322
1322
  var r2 = sniffer$1.os;
@@ -1461,7 +1461,7 @@ var __publicField = (obj, key, value) => {
1461
1461
  }
1462
1462
  }
1463
1463
  };
1464
- var version = "3.0.20-rc.6";
1464
+ var version = "3.0.19-rc.0";
1465
1465
  var ERROR_TYPE_MAP = {
1466
1466
  1: "media",
1467
1467
  2: "media",
@@ -2431,7 +2431,8 @@ var __publicField = (obj, key, value) => {
2431
2431
  }
2432
2432
  if (this.__hooks && this.__hooks[hookName]) {
2433
2433
  try {
2434
- var preRet = runHooks(this, hookName, handler);
2434
+ var _this$__hooks$hookNam;
2435
+ var preRet = (_this$__hooks$hookNam = this.__hooks[hookName]).call.apply(_this$__hooks$hookNam, [this, this].concat(Array.prototype.slice.call(arguments)));
2435
2436
  if (preRet) {
2436
2437
  if (preRet.then) {
2437
2438
  preRet.then(function(isContinue) {
@@ -2456,19 +2457,6 @@ var __publicField = (obj, key, value) => {
2456
2457
  }
2457
2458
  }.bind(this);
2458
2459
  }
2459
- function findHookIndex(hookName, handler) {
2460
- var __hooks = this.__hooks;
2461
- if (!__hooks || !Array.isArray(__hooks[hookName])) {
2462
- return -1;
2463
- }
2464
- var hookHandlers = __hooks[hookName];
2465
- for (var i2 = 0; i2 < hookHandlers.length; i2++) {
2466
- if (hookHandlers[i2] === handler) {
2467
- return i2;
2468
- }
2469
- }
2470
- return -1;
2471
- }
2472
2460
  function useHooks(hookName, handler) {
2473
2461
  var __hooks = this.__hooks;
2474
2462
  if (!__hooks) {
@@ -2478,12 +2466,7 @@ var __publicField = (obj, key, value) => {
2478
2466
  console.warn("has no supported hook which name [".concat(hookName, "]"));
2479
2467
  return false;
2480
2468
  }
2481
- if (!Array.isArray(__hooks[hookName])) {
2482
- __hooks[hookName] = [];
2483
- }
2484
- if (findHookIndex.call(this, hookName, handler) === -1) {
2485
- __hooks[hookName].push(handler);
2486
- }
2469
+ __hooks && (__hooks[hookName] = handler);
2487
2470
  return true;
2488
2471
  }
2489
2472
  function removeHooks(hookName, handler) {
@@ -2491,13 +2474,6 @@ var __publicField = (obj, key, value) => {
2491
2474
  if (!__hooks) {
2492
2475
  return;
2493
2476
  }
2494
- if (Array.isArray(__hooks[hookName])) {
2495
- var hooks = __hooks[hookName];
2496
- var index = findHookIndex.call(this, hookName, handler);
2497
- if (index !== -1) {
2498
- hooks.splice(index, 1);
2499
- }
2500
- }
2501
2477
  delete __hooks[hookName];
2502
2478
  }
2503
2479
  function usePluginHooks(pluginName) {
@@ -2545,30 +2521,18 @@ var __publicField = (obj, key, value) => {
2545
2521
  for (var _len5 = arguments.length, args = new Array(_len5 > 3 ? _len5 - 3 : 0), _key5 = 3; _key5 < _len5; _key5++) {
2546
2522
  args[_key5 - 3] = arguments[_key5];
2547
2523
  }
2548
- if (obj.__hooks && Array.isArray(obj.__hooks[hookName])) {
2549
- var hooks = obj.__hooks[hookName];
2550
- var index = -1;
2551
- var runHooksRecursive = function runHooksRecursive2(obj2, hookName2, handler2) {
2552
- for (var _len6 = arguments.length, args2 = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) {
2553
- args2[_key6 - 3] = arguments[_key6];
2554
- }
2555
- index++;
2556
- if (hooks.length === 0 || index === hooks.length) {
2557
- return handler2.call.apply(handler2, [obj2, obj2].concat(args2));
2558
- }
2559
- var hook2 = hooks[index];
2560
- var ret = hook2.call.apply(hook2, [obj2, obj2].concat(args2));
2561
- if (ret && ret.then) {
2562
- return ret.then(function(data) {
2563
- return data === false ? null : runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
2564
- }).catch(function(e2) {
2565
- console.warn("[runHooks]".concat(hookName2, " reject"), e2.message);
2566
- });
2567
- } else if (ret !== false) {
2568
- return runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
2569
- }
2570
- };
2571
- return runHooksRecursive.apply(void 0, [obj, hookName, handler].concat(args));
2524
+ if (obj.__hooks && obj.__hooks[hookName]) {
2525
+ var _obj$__hooks$hookName;
2526
+ var ret = (_obj$__hooks$hookName = obj.__hooks[hookName]).call.apply(_obj$__hooks$hookName, [obj, obj].concat(args));
2527
+ if (ret && ret.then) {
2528
+ ret.then(function(data) {
2529
+ return data === false ? null : handler.call.apply(handler, [obj, obj].concat(args));
2530
+ }).catch(function(e2) {
2531
+ console.warn("[runHooks]".concat(hookName, " reject"), e2.message);
2532
+ });
2533
+ } else if (ret !== false) {
2534
+ return handler.call.apply(handler, [obj, obj].concat(args));
2535
+ }
2572
2536
  } else {
2573
2537
  return handler.call.apply(handler, [obj, obj].concat(args));
2574
2538
  }
@@ -2812,18 +2776,6 @@ var __publicField = (obj, key, value) => {
2812
2776
  }
2813
2777
  }
2814
2778
  }
2815
- }, {
2816
- key: "defineMethod",
2817
- value: function defineMethod(Obj, map) {
2818
- for (var key in map) {
2819
- if (Object.prototype.hasOwnProperty.call(map, key) && typeof map[key] === "function") {
2820
- Object.defineProperty(Obj, key, {
2821
- configurable: true,
2822
- value: map[key]
2823
- });
2824
- }
2825
- }
2826
- }
2827
2779
  }, {
2828
2780
  key: "defaultConfig",
2829
2781
  get: function get() {
@@ -3469,7 +3421,7 @@ var __publicField = (obj, key, value) => {
3469
3421
  if (!this.observer) {
3470
3422
  return;
3471
3423
  }
3472
- this.observer.observe(target);
3424
+ this.observer && this.observer.observe(target);
3473
3425
  var _pid = target.getAttribute(PLATER_ID);
3474
3426
  var __handlers = this.__handlers;
3475
3427
  var index = -1;
@@ -3498,17 +3450,16 @@ var __publicField = (obj, key, value) => {
3498
3450
  }
3499
3451
  });
3500
3452
  try {
3501
- var _this$observer;
3502
- (_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.unobserve(target);
3453
+ this.observer && this.observer.unobserve(target);
3503
3454
  } catch (e2) {
3504
3455
  }
3456
+ this.observer && this.observer.unobserve(target);
3505
3457
  i2 > -1 && this.__handlers.splice(i2, 1);
3506
3458
  }
3507
3459
  }, {
3508
3460
  key: "destroyObserver",
3509
3461
  value: function destroyObserver() {
3510
- var _this$observer2;
3511
- (_this$observer2 = this.observer) === null || _this$observer2 === void 0 ? void 0 : _this$observer2.disconnect();
3462
+ this.observer && this.observer.disconnect();
3512
3463
  this.observer = null;
3513
3464
  this.__handlers = null;
3514
3465
  }
@@ -3540,8 +3491,7 @@ var __publicField = (obj, key, value) => {
3540
3491
  return resizeObserver;
3541
3492
  }
3542
3493
  function unObserver(target, handler) {
3543
- var _resizeObserver;
3544
- (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.unObserver(target, handler);
3494
+ resizeObserver.unObserver(target, handler);
3545
3495
  }
3546
3496
  var pluginsManager = {
3547
3497
  pluginGroup: {},
@@ -4539,7 +4489,10 @@ var __publicField = (obj, key, value) => {
4539
4489
  }
4540
4490
  var _this$config = _this.config, autoplay2 = _this$config.autoplay, defaultPlaybackRate = _this$config.defaultPlaybackRate;
4541
4491
  XG_DEBUG.logInfo("player", "canPlayFunc, startTime", _this.__startTime);
4542
- _this._seekToStartTime();
4492
+ if (_this.__startTime > 0 && _this.duration > 0) {
4493
+ _this.currentTime = _this.__startTime > _this.duration ? _this.duration : _this.__startTime;
4494
+ _this.__startTime = -1;
4495
+ }
4543
4496
  _this.playbackRate = defaultPlaybackRate;
4544
4497
  (autoplay2 || _this._useAutoplay) && _this.mediaPlay();
4545
4498
  _this.off(CANPLAY, _this.canPlayFunc);
@@ -4629,7 +4582,6 @@ var __publicField = (obj, key, value) => {
4629
4582
  _this.waitTimer = null;
4630
4583
  _this.handleSource = true;
4631
4584
  _this._state = STATES.INITIAL;
4632
- _this.isAd = false;
4633
4585
  _this.isError = false;
4634
4586
  _this._hasStart = false;
4635
4587
  _this.isSeeking = false;
@@ -5014,8 +4966,7 @@ var __publicField = (obj, key, value) => {
5014
4966
  _pConfig.position && (options.position = _pConfig.position);
5015
4967
  var position = options.position ? options.position : options.config && options.config.position || PLUFGIN.defaultConfig && PLUFGIN.defaultConfig.position;
5016
4968
  if (!options.root && typeof position === "string" && position.indexOf("controls") > -1) {
5017
- var _this$controls;
5018
- return (_this$controls = this.controls) === null || _this$controls === void 0 ? void 0 : _this$controls.registerPlugin(PLUFGIN, options, PLUFGIN.pluginName);
4969
+ return this.controls && this.controls.registerPlugin(PLUFGIN, options, PLUFGIN.pluginName);
5019
4970
  }
5020
4971
  if (!options.root) {
5021
4972
  options.root = this._getRootByPosition(position);
@@ -5163,7 +5114,10 @@ var __publicField = (obj, key, value) => {
5163
5114
  reject(e2);
5164
5115
  };
5165
5116
  var _canplay = function _canplay2() {
5166
- _this9._seekToStartTime();
5117
+ if (_this9.duration > 0 && _this9.__startTime > 0) {
5118
+ _this9.currentTime = _this9.__startTime;
5119
+ _this9.__startTime = -1;
5120
+ }
5167
5121
  if (isPaused) {
5168
5122
  _this9.pause();
5169
5123
  }
@@ -5784,17 +5738,11 @@ var __publicField = (obj, key, value) => {
5784
5738
  }, {
5785
5739
  key: "onLoadeddata",
5786
5740
  value: function onLoadeddata() {
5787
- var _this22 = this;
5788
5741
  this.isError = false;
5789
5742
  this.isSeeking = false;
5790
- if (this.__startTime > 0) {
5791
- if (this.duration > 0) {
5792
- this._seekToStartTime();
5793
- } else {
5794
- this.once(DURATION_CHANGE, function() {
5795
- _this22._seekToStartTime();
5796
- });
5797
- }
5743
+ if (this.__startTime > 0 && this.duration > 0) {
5744
+ this.currentTime = this.__startTime;
5745
+ this.__startTime = -1;
5798
5746
  }
5799
5747
  }
5800
5748
  }, {
@@ -5863,27 +5811,27 @@ var __publicField = (obj, key, value) => {
5863
5811
  }, {
5864
5812
  key: "onWaiting",
5865
5813
  value: function onWaiting() {
5866
- var _this23 = this;
5814
+ var _this22 = this;
5867
5815
  if (this.waitTimer) {
5868
5816
  util$1.clearTimeout(this, this.waitTimer);
5869
5817
  }
5870
5818
  this.updateAcc("waiting");
5871
5819
  this.waitTimer = util$1.setTimeout(this, function() {
5872
- _this23.addClass(STATE_CLASS.LOADING);
5873
- _this23.emit(LOADING);
5874
- util$1.clearTimeout(_this23, _this23.waitTimer);
5875
- _this23.waitTimer = null;
5820
+ _this22.addClass(STATE_CLASS.LOADING);
5821
+ _this22.emit(LOADING);
5822
+ util$1.clearTimeout(_this22, _this22.waitTimer);
5823
+ _this22.waitTimer = null;
5876
5824
  }, this.config.minWaitDelay);
5877
5825
  }
5878
5826
  }, {
5879
5827
  key: "onPlaying",
5880
5828
  value: function onPlaying() {
5881
- var _this24 = this;
5829
+ var _this23 = this;
5882
5830
  this.isError = false;
5883
5831
  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;
5884
5832
  var clsList = [NO_START, PAUSED, ENDED2, ERROR2, REPLAY2, LOADING2];
5885
5833
  clsList.forEach(function(cls) {
5886
- _this24.removeClass(cls);
5834
+ _this23.removeClass(cls);
5887
5835
  });
5888
5836
  if (!this._accPlayed.t && !this.paused && !this.ended) {
5889
5837
  this._accPlayed.t = (/* @__PURE__ */ new Date()).getTime();
@@ -6044,14 +5992,14 @@ var __publicField = (obj, key, value) => {
6044
5992
  }, {
6045
5993
  key: "setConfig",
6046
5994
  value: function setConfig(config) {
6047
- var _this25 = this;
5995
+ var _this24 = this;
6048
5996
  if (!config) {
6049
5997
  return;
6050
5998
  }
6051
5999
  Object.keys(config).map(function(key) {
6052
6000
  if (key !== "plugins") {
6053
- _this25.config[key] = config[key];
6054
- var plugin = _this25.plugins[key.toLowerCase()];
6001
+ _this24.config[key] = config[key];
6002
+ var plugin = _this24.plugins[key.toLowerCase()];
6055
6003
  if (plugin && util$1.typeOf(plugin.setConfig) === "Function") {
6056
6004
  plugin.setConfig(config[key]);
6057
6005
  }
@@ -6061,20 +6009,20 @@ var __publicField = (obj, key, value) => {
6061
6009
  }, {
6062
6010
  key: "playNext",
6063
6011
  value: function playNext(config) {
6064
- var _this26 = this;
6012
+ var _this25 = this;
6065
6013
  this.resetState();
6066
6014
  this.setConfig(config);
6067
6015
  this._currentTime = 0;
6068
6016
  this._duration = 0;
6069
6017
  runHooks(this, "playnext", function() {
6070
- _this26.start();
6071
- _this26.emit(PLAYNEXT, config);
6018
+ _this25.start();
6019
+ _this25.emit(PLAYNEXT, config);
6072
6020
  });
6073
6021
  }
6074
6022
  }, {
6075
6023
  key: "resize",
6076
6024
  value: function resize() {
6077
- var _this27 = this;
6025
+ var _this26 = this;
6078
6026
  if (!this.media) {
6079
6027
  return;
6080
6028
  }
@@ -6114,7 +6062,7 @@ var __publicField = (obj, key, value) => {
6114
6062
  }
6115
6063
  if (!this.fullscreen && !this.cssfullscreen) {
6116
6064
  Object.keys(_style).forEach(function(key) {
6117
- _this27.root.style[key] = _style[key];
6065
+ _this26.root.style[key] = _style[key];
6118
6066
  });
6119
6067
  }
6120
6068
  if (videoFillMode === "fillHeight" && fit < videoFit || videoFillMode === "fillWidth" && fit > videoFit) {
@@ -6156,14 +6104,6 @@ var __publicField = (obj, key, value) => {
6156
6104
  url
6157
6105
  };
6158
6106
  }
6159
- }, {
6160
- key: "_seekToStartTime",
6161
- value: function _seekToStartTime() {
6162
- if (this.__startTime > 0 && this.duration > 0) {
6163
- this.currentTime = this.__startTime > this.duration ? this.duration : this.__startTime;
6164
- this.__startTime = -1;
6165
- }
6166
- }
6167
6107
  }, {
6168
6108
  key: "state",
6169
6109
  get: function get() {
@@ -6214,15 +6154,15 @@ var __publicField = (obj, key, value) => {
6214
6154
  return this.config.definition.list || [];
6215
6155
  },
6216
6156
  set: function set(list) {
6217
- var _this28 = this;
6157
+ var _this27 = this;
6218
6158
  var definition = this.config.definition;
6219
6159
  var curDef = null;
6220
6160
  var targetDef = null;
6221
6161
  definition.list = list;
6222
6162
  this.emit("resourceReady", list);
6223
6163
  list.forEach(function(item) {
6224
- var _this28$curDefinition;
6225
- if (((_this28$curDefinition = _this28.curDefinition) === null || _this28$curDefinition === void 0 ? void 0 : _this28$curDefinition.definition) === item.definition) {
6164
+ var _this27$curDefinition;
6165
+ if (((_this27$curDefinition = _this27.curDefinition) === null || _this27$curDefinition === void 0 ? void 0 : _this27$curDefinition.definition) === item.definition) {
6226
6166
  curDef = item;
6227
6167
  }
6228
6168
  if (definition.defaultDefinition === item.definition) {
@@ -6734,11 +6674,11 @@ var __publicField = (obj, key, value) => {
6734
6674
  } : error2;
6735
6675
  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"));
6736
6676
  super(message);
6737
- /**
6677
+ /** {zh}
6738
6678
  * @brief 错误码。
6739
6679
  */
6740
6680
  /** {en}
6741
- * @brief The error code.
6681
+ * @brief Error code.
6742
6682
  */
6743
6683
  __publicField(this, "errorCode");
6744
6684
  /** {zh}
@@ -6986,7 +6926,7 @@ var __publicField = (obj, key, value) => {
6986
6926
  var className = _this.config.mode === "auto" ? "auto-hide" : "hide";
6987
6927
  util$1.addClass(_this.root, className);
6988
6928
  _this.autoPlayStart = true;
6989
- _this.toggleTo("play");
6929
+ _this.onPlayPause("play");
6990
6930
  });
6991
6931
  _this.autoPlayStart = false;
6992
6932
  return _this;
@@ -6994,19 +6934,9 @@ var __publicField = (obj, key, value) => {
6994
6934
  _createClass$1(Start2, [{
6995
6935
  key: "afterCreate",
6996
6936
  value: function afterCreate() {
6997
- var playerConfig = this.playerConfig;
6998
- this.initIcons();
6999
- this.listenEvents();
7000
- this.bindClickEvents();
7001
- if (!playerConfig.autoplay) {
7002
- this.show();
7003
- }
7004
- }
7005
- }, {
7006
- key: "listenEvents",
7007
- value: function listenEvents() {
7008
6937
  var _this2 = this;
7009
6938
  var player = this.player, playerConfig = this.playerConfig;
6939
+ this.initIcons();
7010
6940
  this.once(READY, function() {
7011
6941
  if (playerConfig) {
7012
6942
  if (playerConfig.lang && playerConfig.lang === "en") {
@@ -7017,6 +6947,9 @@ var __publicField = (obj, key, value) => {
7017
6947
  }
7018
6948
  });
7019
6949
  this.on(AUTOPLAY_STARTED, this.onAutoplayStart);
6950
+ if (!playerConfig.autoplay) {
6951
+ this.show();
6952
+ }
7020
6953
  this.on(AUTOPLAY_PREVENTED, function() {
7021
6954
  var className = _this2.config.mode === "auto" ? "auto-hide" : "hide";
7022
6955
  _this2.setAttr("data-state", "play");
@@ -7024,25 +6957,20 @@ var __publicField = (obj, key, value) => {
7024
6957
  _this2.show();
7025
6958
  });
7026
6959
  this.on(PLAY, function() {
7027
- _this2.toggleTo("play");
6960
+ _this2.onPlayPause("play");
7028
6961
  });
7029
6962
  this.on(PAUSE, function() {
7030
- _this2.toggleTo("pause");
6963
+ _this2.onPlayPause("pause");
7031
6964
  });
7032
6965
  this.on(RESET, function() {
7033
6966
  _this2.onPlayerReset();
7034
6967
  });
7035
- }
7036
- }, {
7037
- key: "bindClickEvents",
7038
- value: function bindClickEvents() {
7039
- var _this3 = this;
7040
6968
  this.clickHandler = this.hook("startClick", this.switchPausePlay, {
7041
6969
  pre: function pre(e2) {
7042
6970
  e2.cancelable && e2.preventDefault();
7043
6971
  e2.stopPropagation();
7044
- var paused = _this3.player.paused;
7045
- _this3.emitUserAction(e2, "switch_play_pause", {
6972
+ var paused = _this2.player.paused;
6973
+ _this2.emitUserAction(e2, "switch_play_pause", {
7046
6974
  props: "paused",
7047
6975
  from: paused,
7048
6976
  to: !paused
@@ -7104,17 +7032,17 @@ var __publicField = (obj, key, value) => {
7104
7032
  }, {
7105
7033
  key: "animate",
7106
7034
  value: function animate(endShow) {
7107
- var _this4 = this;
7035
+ var _this3 = this;
7108
7036
  this._animateId = addAnimate("pauseplay", 400, {
7109
7037
  start: function start() {
7110
- util$1.addClass(_this4.root, "interact");
7111
- _this4.show();
7112
- _this4.switchStatus(true);
7038
+ util$1.addClass(_this3.root, "interact");
7039
+ _this3.show();
7040
+ _this3.switchStatus(true);
7113
7041
  },
7114
7042
  end: function end() {
7115
- util$1.removeClass(_this4.root, "interact");
7116
- !endShow && _this4.hide();
7117
- _this4._animateId = null;
7043
+ util$1.removeClass(_this3.root, "interact");
7044
+ !endShow && _this3.hide();
7045
+ _this3._animateId = null;
7118
7046
  }
7119
7047
  });
7120
7048
  }
@@ -7144,11 +7072,6 @@ var __publicField = (obj, key, value) => {
7144
7072
  }, {
7145
7073
  key: "onPlayPause",
7146
7074
  value: function onPlayPause(status) {
7147
- this.toggleTo(status);
7148
- }
7149
- }, {
7150
- key: "toggleTo",
7151
- value: function toggleTo(status) {
7152
7075
  var config = this.config, player = this.player;
7153
7076
  if (!player || player.state < STATES.RUNNING || !this.autoPlayStart) {
7154
7077
  return;
@@ -8524,7 +8447,7 @@ var __publicField = (obj, key, value) => {
8524
8447
  }
8525
8448
  this.on(DURATION_CHANGE, function() {
8526
8449
  var player2 = _this2.player, config2 = _this2.config;
8527
- if (player2.duration > 0 && player2.duration * 1e3 < config2.moveDuration) {
8450
+ if (player2.duration * 1e3 < config2.moveDuration) {
8528
8451
  config2.moveDuration = player2.duration * 1e3;
8529
8452
  }
8530
8453
  });
@@ -8838,13 +8761,10 @@ var __publicField = (obj, key, value) => {
8838
8761
  }, {
8839
8762
  key: "updateBrightness",
8840
8763
  value: function updateBrightness(percent) {
8841
- var pos = this.pos, config = this.config, xgMask = this.xgMask;
8842
- if (!config.darkness) {
8843
- return;
8844
- }
8845
8764
  if (this.player.rotateDeg) {
8846
8765
  percent = -percent;
8847
8766
  }
8767
+ var pos = this.pos, config = this.config, xgMask = this.xgMask;
8848
8768
  var light = pos.light + 0.8 * percent;
8849
8769
  light = light > config.maxDarkness ? config.maxDarkness : light < 0 ? 0 : light;
8850
8770
  if (xgMask) {
@@ -8905,12 +8825,12 @@ var __publicField = (obj, key, value) => {
8905
8825
  }, {
8906
8826
  key: "disableGesture",
8907
8827
  value: function disableGesture() {
8908
- this.config.disableGesture = true;
8828
+ this.config.disableGesture = false;
8909
8829
  }
8910
8830
  }, {
8911
8831
  key: "enableGesture",
8912
8832
  value: function enableGesture() {
8913
- this.config.disableGesture = false;
8833
+ this.config.disableGesture = true;
8914
8834
  }
8915
8835
  }, {
8916
8836
  key: "destroy",
@@ -9482,55 +9402,28 @@ var __publicField = (obj, key, value) => {
9482
9402
  _inherits(Play2, _IconPlugin);
9483
9403
  var _super = _createSuper(Play2);
9484
9404
  function Play2() {
9485
- var _this;
9486
9405
  _classCallCheck(this, Play2);
9487
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9488
- args[_key] = arguments[_key];
9489
- }
9490
- _this = _super.call.apply(_super, [this].concat(args));
9491
- _defineProperty$1(_assertThisInitialized(_this), "btnClick", function(e2) {
9492
- e2.preventDefault();
9493
- e2.stopPropagation();
9494
- var _assertThisInitialize = _assertThisInitialized(_this), player = _assertThisInitialize.player;
9495
- _this.emitUserAction(e2, "switch_play_pause", {
9496
- prop: "paused",
9497
- from: player.paused,
9498
- to: !player.paused
9499
- });
9500
- if (player.ended) {
9501
- player.replay();
9502
- } else if (player.paused) {
9503
- player.play();
9504
- _this.animate(false);
9505
- } else {
9506
- player.pause();
9507
- _this.animate(true);
9508
- }
9509
- return false;
9510
- });
9511
- return _this;
9406
+ return _super.apply(this, arguments);
9512
9407
  }
9513
9408
  _createClass$1(Play2, [{
9514
9409
  key: "afterCreate",
9515
9410
  value: function afterCreate() {
9411
+ var _this = this;
9516
9412
  _get(_getPrototypeOf(Play2.prototype), "afterCreate", this).call(this);
9517
- var config = this.config;
9413
+ var player = this.player, config = this.config;
9518
9414
  if (config.disable) {
9519
9415
  return;
9520
9416
  }
9521
9417
  this.initIcons();
9418
+ this.btnClick = this.btnClick.bind(this);
9522
9419
  this.bind(["touchend", "click"], this.btnClick);
9523
- this.listenEvents();
9524
- this.animate(true);
9525
- }
9526
- }, {
9527
- key: "listenEvents",
9528
- value: function listenEvents() {
9529
- var _this2 = this;
9530
- var player = this.player;
9531
- this.on([PLAY, PAUSE, ERROR, EMPTIED], function() {
9532
- _this2.animate(player.paused);
9420
+ this.on([PAUSE, ERROR, EMPTIED], function() {
9421
+ _this.animate(player.paused);
9533
9422
  });
9423
+ this.on(PLAY, function() {
9424
+ _this.animate(player.paused);
9425
+ });
9426
+ this.animate(true);
9534
9427
  }
9535
9428
  }, {
9536
9429
  key: "registerIcons",
@@ -9546,6 +9439,28 @@ var __publicField = (obj, key, value) => {
9546
9439
  }
9547
9440
  };
9548
9441
  }
9442
+ }, {
9443
+ key: "btnClick",
9444
+ value: function btnClick(e2) {
9445
+ e2.preventDefault();
9446
+ e2.stopPropagation();
9447
+ var player = this.player;
9448
+ this.emitUserAction(e2, "switch_play_pause", {
9449
+ prop: "paused",
9450
+ from: player.paused,
9451
+ to: !player.paused
9452
+ });
9453
+ if (player.ended) {
9454
+ player.replay();
9455
+ } else if (player.paused) {
9456
+ player.play();
9457
+ this.animate(false);
9458
+ } else {
9459
+ player.pause();
9460
+ this.animate(true);
9461
+ }
9462
+ return false;
9463
+ }
9549
9464
  }, {
9550
9465
  key: "initIcons",
9551
9466
  value: function initIcons() {
@@ -11664,10 +11579,10 @@ var __publicField = (obj, key, value) => {
11664
11579
  const { controls } = this.player;
11665
11580
  const { listType } = this.config;
11666
11581
  if (isActive) {
11667
- listType && MODAL_TYPES.includes(listType) ? controls == null ? void 0 : controls.blur() : controls == null ? void 0 : controls.focus();
11582
+ listType && MODAL_TYPES.includes(listType) ? controls.blur() : controls.focus();
11668
11583
  this.optionsList && this.optionsList.show();
11669
11584
  } else {
11670
- listType && MODAL_TYPES.includes(listType) ? controls == null ? void 0 : controls.focus() : controls == null ? void 0 : controls.focusAwhile();
11585
+ listType && MODAL_TYPES.includes(listType) ? controls.focus() : controls.focusAwhile();
11671
11586
  this.optionsList && this.optionsList.hide();
11672
11587
  }
11673
11588
  this._isActive = isActive;
@@ -13593,28 +13508,33 @@ var __publicField = (obj, key, value) => {
13593
13508
  useCssFullscreen: false
13594
13509
  }
13595
13510
  };
13596
- const transformOption = (options) => {
13597
- const { autoplay: autoplay2, ...rest } = options;
13598
- const xgOptions = rest;
13599
- if (xgOptions.poster) {
13600
- xgOptions.poster = escapeHtml(xgOptions.poster);
13601
- }
13602
- xgOptions.icons = {
13603
- ...DEFAULT_ICONS,
13604
- ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13605
- };
13606
- xgOptions.autoplay = Boolean(autoplay2);
13607
- if (autoplay2 && typeof autoplay2 !== "boolean") {
13608
- xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13609
- xgOptions.videoAttributes = {
13610
- ...xgOptions.videoAttributes ?? {},
13611
- muted: autoplay2 == null ? void 0 : autoplay2.muted
13511
+ const transformOption = (
13512
+ /** {zh}
13513
+ * @param options 更多配置信息。
13514
+ */
13515
+ (options) => {
13516
+ const { autoplay: autoplay2, ...rest } = options;
13517
+ const xgOptions = rest;
13518
+ if (xgOptions.poster) {
13519
+ xgOptions.poster = escapeHtml(xgOptions.poster);
13520
+ }
13521
+ xgOptions.icons = {
13522
+ ...DEFAULT_ICONS,
13523
+ ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13612
13524
  };
13613
- xgOptions.autoplayPlugin = autoplay2;
13525
+ xgOptions.autoplay = Boolean(autoplay2);
13526
+ if (autoplay2 && typeof autoplay2 !== "boolean") {
13527
+ xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13528
+ xgOptions.videoAttributes = {
13529
+ ...xgOptions.videoAttributes ?? {},
13530
+ muted: autoplay2 == null ? void 0 : autoplay2.muted
13531
+ };
13532
+ xgOptions.autoplayPlugin = autoplay2;
13533
+ }
13534
+ delete xgOptions.i18n;
13535
+ return xgOptions;
13614
13536
  }
13615
- delete xgOptions.i18n;
13616
- return xgOptions;
13617
- };
13537
+ );
13618
13538
  class VePlayerBase {
13619
13539
  /** {zh}
13620
13540
  * @hidden
@@ -13634,7 +13554,9 @@ var __publicField = (obj, key, value) => {
13634
13554
  this._sourceManager = options.sourceManager;
13635
13555
  this._preparePlugins = options.preparePlugins;
13636
13556
  this._previousPrepareResult = options.prepareResult;
13637
- this._i18nManager = options.i18nManager ?? new VeI18n({ i18n: options.i18n });
13557
+ this._i18nManager = options.i18nManager ?? new VeI18n({
13558
+ i18n: options.i18n
13559
+ });
13638
13560
  const xgOptions = transformOption({
13639
13561
  ...options,
13640
13562
  ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
@@ -13829,9 +13751,14 @@ var __publicField = (obj, key, value) => {
13829
13751
  /** {zh}
13830
13752
  * 获取播放器版本号
13831
13753
  * @returns
13754
+ * @brief
13755
+ * 获取播放器 SDK 版本号。
13756
+ */
13757
+ /** {en}
13758
+ * @brief Retrieve the player SDK version number.
13832
13759
  */
13833
13760
  get playerVersion() {
13834
- return "2.4.3-rc.1";
13761
+ return "2.4.5-rc.0";
13835
13762
  }
13836
13763
  /** {zh}
13837
13764
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -13979,8 +13906,8 @@ var __publicField = (obj, key, value) => {
13979
13906
  }
13980
13907
  /** {zh}
13981
13908
  * @brief 调用此方法切换拉流地址、线路、清晰度。
13982
- * @param target 目标地址,可以是播放地址,也可以是线路和清晰度
13983
- * @param options 更多配置信息
13909
+ * @param target 目标地址,可以是播放地址,也可以是线路和清晰度。
13910
+ * @param options 更多配置信息。
13984
13911
  */
13985
13912
  /** {en}
13986
13913
  * @brief Switches the pull stream address, playback source, or resolution.
@@ -13991,7 +13918,9 @@ var __publicField = (obj, key, value) => {
13991
13918
  var _a, _b;
13992
13919
  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) {
13993
13920
  this._sourceManager.updateSources(target);
13994
- await this._switchUrl(target, { seamless: options == null ? void 0 : options.seamless });
13921
+ await this._switchUrl(target, {
13922
+ seamless: options == null ? void 0 : options.seamless
13923
+ });
13995
13924
  return this._sourceManager.definition;
13996
13925
  }
13997
13926
  const targetDefinition = this._sourceManager.find(target, options);
@@ -14018,16 +13947,15 @@ var __publicField = (obj, key, value) => {
14018
13947
  return this._switch(sourceManager.definition);
14019
13948
  }
14020
13949
  // TODO: 等西瓜播放器完善错误码后增加函数重载以提供更好的类型
14021
- /**
14022
13950
  /** {zh}
14023
13951
  * @brief 调用此方法监听指定事件,事件处理函数只执行一次。
14024
13952
  * @param event 表示事件的名称。
14025
13953
  * @param callback 表示事件的回调函数。
14026
13954
  */
14027
13955
  /** {en}
14028
- * @brief Add a one-time listener function for the specified event.
14029
- * @param event The event name.
14030
- * @param callback The callback function for the event.
13956
+ * @brief Call this method to listen for the specified event. The event handler is executed only once.
13957
+ * @param event The name representing the event.
13958
+ * @param callback Callback functions representing events.
14031
13959
  */
14032
13960
  once(event, callback) {
14033
13961
  var _a;
@@ -14178,10 +14106,14 @@ var __publicField = (obj, key, value) => {
14178
14106
  return this._player.blur(data);
14179
14107
  }
14180
14108
  /** {zh}
14181
- * @brief 判断浏览器是否支持播放格式
14182
- * @param type 播放格式
14109
+ * @brief 判断浏览器是否支持播放格式。
14110
+ * @param type 播放格式。
14183
14111
  * @returns
14184
14112
  */
14113
+ /** {en}
14114
+ * @brief Determine whether the browser supports the playback format.
14115
+ * @param type The playback format.
14116
+ */
14185
14117
  canPlayType(type) {
14186
14118
  return this._player.canPlayType(type);
14187
14119
  }
@@ -14253,7 +14185,7 @@ var __publicField = (obj, key, value) => {
14253
14185
  }
14254
14186
  /** {zh}
14255
14187
  * @brief 调用此接口显示指定插件图标。
14256
- * @param pluginNames 插件名称
14188
+ * @param pluginNames 插件名称。
14257
14189
  */
14258
14190
  /** {en}
14259
14191
  * @brief Displays the icon of a specified plugin.
@@ -14274,7 +14206,7 @@ var __publicField = (obj, key, value) => {
14274
14206
  }
14275
14207
  /** {zh}
14276
14208
  * @brief 调用此接口隐藏指定插件图标。
14277
- * @param pluginNames 插件名称
14209
+ * @param pluginNames 插件名称。
14278
14210
  */
14279
14211
  /** {en}
14280
14212
  * @brief Hides the icon of a specified plugin.
@@ -14346,7 +14278,14 @@ var __publicField = (obj, key, value) => {
14346
14278
  this._player.once("canplay", () => {
14347
14279
  this._sourceManager.resetFallback();
14348
14280
  });
14349
- this.emit(Events$1.FALLBACK, { from: { url: preUrl }, to: { url } });
14281
+ this.emit(Events$1.FALLBACK, {
14282
+ from: {
14283
+ url: preUrl
14284
+ },
14285
+ to: {
14286
+ url
14287
+ }
14288
+ });
14350
14289
  this._switchUrl(url);
14351
14290
  }
14352
14291
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -22083,9 +22022,9 @@ var __publicField = (obj, key, value) => {
22083
22022
  user_id: this._userId,
22084
22023
  device_id: this._deviceId,
22085
22024
  ext: {
22086
- veplayer_version: "2.4.3-rc.1",
22087
- flv_version: "v3.0.20-rc.6",
22088
- hls_version: "3.0.20-alpha.3",
22025
+ veplayer_version: "2.4.5-rc.0",
22026
+ flv_version: "3.0.19-rc.0",
22027
+ hls_version: "3.0.19-rc.0",
22089
22028
  rts_version: "0.2.1-alpha.0"
22090
22029
  }
22091
22030
  });
@@ -22122,7 +22061,7 @@ var __publicField = (obj, key, value) => {
22122
22061
  {
22123
22062
  key: "resolution",
22124
22063
  labelTextKey: "RESOLUTION",
22125
- value: `${normalizeNumber(data.height)} * ${normalizeNumber(
22064
+ value: `${normalizeNumber(data.width)} * ${normalizeNumber(
22126
22065
  data.height
22127
22066
  )}`
22128
22067
  },
@@ -22414,7 +22353,9 @@ var __publicField = (obj, key, value) => {
22414
22353
  }
22415
22354
  ]);
22416
22355
  const LIVE_DEFAULT_OPTIONS = {
22417
- autoplay: { muted: true }
22356
+ autoplay: {
22357
+ muted: true
22358
+ }
22418
22359
  };
22419
22360
  const LIVE_DEFAULT_PLUGINS = [...DEFAULT_PLUGINS, Refresh, Logger, InfoPanel];
22420
22361
  var RTMCodec = /* @__PURE__ */ ((RTMCodec2) => {
@@ -22434,7 +22375,10 @@ var __publicField = (obj, key, value) => {
22434
22375
  super(options);
22435
22376
  }
22436
22377
  /** {zh}
22437
- * @brief 获取已经播放的时间
22378
+ * @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
22379
+ */
22380
+ /** {en}
22381
+ * @brief Obtain the duration that has been played, excluding pause and waiting time, with the unit of seconds.
22438
22382
  */
22439
22383
  get playTime() {
22440
22384
  var _a, _b, _c, _d;
@@ -22493,7 +22437,10 @@ var __publicField = (obj, key, value) => {
22493
22437
  (_a = this._player.plugins) == null ? void 0 : _a.infopanel.close();
22494
22438
  }
22495
22439
  /** {zh}
22496
- * @brief 打开 Abr
22440
+ * @brief 打开码率自适应(ABR)切换功能。
22441
+ */
22442
+ /** {en}
22443
+ * @brief Enable the Adaptive Bitrate Streaming (ABR) switching feature.
22497
22444
  */
22498
22445
  openAbr() {
22499
22446
  var _a, _b, _c, _d;
@@ -22507,7 +22454,10 @@ var __publicField = (obj, key, value) => {
22507
22454
  }
22508
22455
  }
22509
22456
  /** {zh}
22510
- * @brief 关闭 Abr
22457
+ * @brief 关闭码率自适应(ABR)切换功能。
22458
+ */
22459
+ /** {en}
22460
+ * @brief Disable the Adaptive Bitrate Streaming (ABR) switching feature.
22511
22461
  */
22512
22462
  closeAbr() {
22513
22463
  var _a, _b, _c, _d;
@@ -22521,18 +22471,25 @@ var __publicField = (obj, key, value) => {
22521
22471
  }
22522
22472
  }
22523
22473
  /** {zh}
22524
- * @brief 调用此方法更新 DRM 鉴权配置。
22525
- * @hidden
22474
+ * @brief 调用此方法更新 DRM 配置。
22475
+ */
22476
+ /** {en}
22477
+ * @brief Use this method to update DRM configuration.
22478
+ * @param config
22526
22479
  */
22527
22480
  updateDrmConfig(config) {
22528
22481
  var _a, _b, _c;
22529
22482
  (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.drm) == null ? void 0 : _c.updateDrmConfig(config);
22530
22483
  }
22531
22484
  /** {zh}
22532
- * @brief 切换 flv Abr
22533
- * @param options 切换 Abr 的配置。
22485
+ * @brief 修改 ABR 配置,包含修改是否开启 ABR 功能,和修改其他清晰度。
22486
+ * @param options ABR 的配置。
22534
22487
  * @returns
22535
22488
  */
22489
+ /** {en}
22490
+ * @brief Modify ABR configuration, including enabling or disabling the ABR feature and adjusting other resolutions.
22491
+ * @param options Configuration of ABR.
22492
+ */
22536
22493
  switchAbr(options) {
22537
22494
  var _a, _b;
22538
22495
  if (!((_a = this._player.plugins) == null ? void 0 : _a.abr)) {
@@ -22543,7 +22500,9 @@ var __publicField = (obj, key, value) => {
22543
22500
  if (!url) {
22544
22501
  return;
22545
22502
  }
22546
- this.switch(url, { seamless: true });
22503
+ this.switch(url, {
22504
+ seamless: true
22505
+ });
22547
22506
  this._player.plugins.abr.bitrate = options.bitrate;
22548
22507
  }
22549
22508
  if (typeof (options == null ? void 0 : options.enable) !== "undefined") {
@@ -22551,25 +22510,34 @@ var __publicField = (obj, key, value) => {
22551
22510
  }
22552
22511
  }
22553
22512
  /** {zh}
22554
- * @brief 获取 RTM 的网络相关信息
22513
+ * @brief 获取 RTM 拉流的网络评估信息。
22555
22514
  * @returns
22556
22515
  */
22516
+ /** {en}
22517
+ * @brief Obtain the network assessment information of RTM pull streaming.
22518
+ */
22557
22519
  getRTMNetWorkInfo() {
22558
22520
  var _a, _b, _c;
22559
22521
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getNetWorkInfo();
22560
22522
  }
22561
22523
  /** {zh}
22562
- * @brief 获取 RTM 播放信息
22524
+ * @brief 获取 RTM 拉流的播放信息。
22563
22525
  * @returns
22564
22526
  */
22527
+ /** {en}
22528
+ * @brief Obtain the playback information of RTM pull stream.
22529
+ */
22565
22530
  async getRTMStats() {
22566
22531
  var _a, _b, _c;
22567
22532
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot();
22568
22533
  }
22569
22534
  /** {zh}
22570
- * @brief 获取 FLV 播放信息
22535
+ * @brief 获取 FLV 拉流的播放信息。
22571
22536
  * @returns
22572
22537
  */
22538
+ /** {en}
22539
+ * @brief Obtain the playback information of FLV pull streaming.
22540
+ */
22573
22541
  getFLVStats() {
22574
22542
  var _a, _b, _c;
22575
22543
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
@@ -22581,7 +22549,10 @@ var __publicField = (obj, key, value) => {
22581
22549
  if (!options || !options.url && !options.playlist) {
22582
22550
  throw create(ErrorCode.INVALID_PARAMETER, new VeI18n());
22583
22551
  }
22584
- const i18n = new VeI18n({ lang: options == null ? void 0 : options.lang, i18n: options == null ? void 0 : options.i18n });
22552
+ const i18n = new VeI18n({
22553
+ lang: options == null ? void 0 : options.lang,
22554
+ i18n: options == null ? void 0 : options.i18n
22555
+ });
22585
22556
  const finalOptions = {
22586
22557
  ...options,
22587
22558
  plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
@@ -22599,9 +22570,24 @@ var __publicField = (obj, key, value) => {
22599
22570
  },
22600
22571
  async preparePlugins(url) {
22601
22572
  const [typeStrategy, drmStrategy, abrStrategy] = await Promise.all([
22602
- getTypeStrategy({ ...finalOptions, url }, player),
22603
- getDrmStrategy({ ...finalOptions, url }, player),
22604
- getAbrStrategy({ ...finalOptions, url })
22573
+ getTypeStrategy(
22574
+ {
22575
+ ...finalOptions,
22576
+ url
22577
+ },
22578
+ player
22579
+ ),
22580
+ getDrmStrategy(
22581
+ {
22582
+ ...finalOptions,
22583
+ url
22584
+ },
22585
+ player
22586
+ ),
22587
+ getAbrStrategy({
22588
+ ...finalOptions,
22589
+ url
22590
+ })
22605
22591
  ]);
22606
22592
  const { options: options2, plugins } = typeStrategy ?? {};
22607
22593
  const { options: drmOptions, plugins: drmPlugins } = drmStrategy ?? {};