@volcengine/veplayer 2.5.0-rc.1 → 2.6.0-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.
@@ -1456,7 +1456,7 @@ var __publicField = (obj, key, value) => {
1456
1456
  }
1457
1457
  }
1458
1458
  };
1459
- var version = "3.0.20-alpha.4";
1459
+ var version = "3.0.21-rc.3";
1460
1460
  var ERROR_TYPE_MAP = {
1461
1461
  1: "media",
1462
1462
  2: "media",
@@ -2807,6 +2807,18 @@ var __publicField = (obj, key, value) => {
2807
2807
  }
2808
2808
  }
2809
2809
  }
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
+ }
2810
2822
  }, {
2811
2823
  key: "defaultConfig",
2812
2824
  get: function get() {
@@ -3452,7 +3464,7 @@ var __publicField = (obj, key, value) => {
3452
3464
  if (!this.observer) {
3453
3465
  return;
3454
3466
  }
3455
- this.observer && this.observer.observe(target);
3467
+ this.observer.observe(target);
3456
3468
  var _pid = target.getAttribute(PLATER_ID);
3457
3469
  var __handlers = this.__handlers;
3458
3470
  var index = -1;
@@ -3481,16 +3493,17 @@ var __publicField = (obj, key, value) => {
3481
3493
  }
3482
3494
  });
3483
3495
  try {
3484
- this.observer && this.observer.unobserve(target);
3496
+ var _this$observer;
3497
+ (_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.unobserve(target);
3485
3498
  } catch (e) {
3486
3499
  }
3487
- this.observer && this.observer.unobserve(target);
3488
3500
  i > -1 && this.__handlers.splice(i, 1);
3489
3501
  }
3490
3502
  }, {
3491
3503
  key: "destroyObserver",
3492
3504
  value: function destroyObserver() {
3493
- this.observer && this.observer.disconnect();
3505
+ var _this$observer2;
3506
+ (_this$observer2 = this.observer) === null || _this$observer2 === void 0 ? void 0 : _this$observer2.disconnect();
3494
3507
  this.observer = null;
3495
3508
  this.__handlers = null;
3496
3509
  }
@@ -3522,7 +3535,8 @@ var __publicField = (obj, key, value) => {
3522
3535
  return resizeObserver;
3523
3536
  }
3524
3537
  function unObserver(target, handler) {
3525
- resizeObserver.unObserver(target, handler);
3538
+ var _resizeObserver;
3539
+ (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.unObserver(target, handler);
3526
3540
  }
3527
3541
  var pluginsManager = {
3528
3542
  pluginGroup: {},
@@ -5114,7 +5128,7 @@ var __publicField = (obj, key, value) => {
5114
5128
  if (!url) {
5115
5129
  url = _this8.url || _this8.config.url;
5116
5130
  }
5117
- var _furl = _this8._preProcessUrl(url);
5131
+ var _furl = _this8.preProcessUrl(url);
5118
5132
  var ret = _this8._startInit(_furl.url);
5119
5133
  return ret;
5120
5134
  }).catch(function(e) {
@@ -5132,7 +5146,7 @@ var __publicField = (obj, key, value) => {
5132
5146
  if (util.typeOf(url) === "Object") {
5133
5147
  _src = url.url;
5134
5148
  }
5135
- _src = this._preProcessUrl(_src).url;
5149
+ _src = this.preProcessUrl(_src).url;
5136
5150
  var curTime = this.currentTime;
5137
5151
  this.__startTime = curTime;
5138
5152
  var isPaused = this.paused && !this.isError;
@@ -5473,7 +5487,7 @@ var __publicField = (obj, key, value) => {
5473
5487
  runHooks(this, "retry", function() {
5474
5488
  var cur = _this20.currentTime;
5475
5489
  var url = _this20.config.url;
5476
- var _srcRet = !util.isMSE(_this20.media) ? _this20._preProcessUrl(url) : {
5490
+ var _srcRet = !util.isMSE(_this20.media) ? _this20.preProcessUrl(url) : {
5477
5491
  url
5478
5492
  };
5479
5493
  _this20.src = _srcRet.url;
@@ -6129,11 +6143,11 @@ var __publicField = (obj, key, value) => {
6129
6143
  this._state = newState;
6130
6144
  }
6131
6145
  }, {
6132
- key: "_preProcessUrl",
6133
- value: function _preProcessUrl(url, ext) {
6134
- var _this$config7 = this.config, preProcessUrl = _this$config7.preProcessUrl, preProcessUrlOptions = _this$config7.preProcessUrlOptions;
6146
+ key: "preProcessUrl",
6147
+ value: function preProcessUrl(url, ext) {
6148
+ var _this$config7 = this.config, preProcessUrl2 = _this$config7.preProcessUrl, preProcessUrlOptions = _this$config7.preProcessUrlOptions;
6135
6149
  var processUrlOptions = Object.assign({}, preProcessUrlOptions, ext);
6136
- return !util.isBlob(url) && typeof preProcessUrl === "function" ? preProcessUrl(url, processUrlOptions) : {
6150
+ return !util.isBlob(url) && typeof preProcessUrl2 === "function" ? preProcessUrl2(url, processUrlOptions) : {
6137
6151
  url
6138
6152
  };
6139
6153
  }
@@ -6699,11 +6713,11 @@ var __publicField = (obj, key, value) => {
6699
6713
  } : error2;
6700
6714
  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"));
6701
6715
  super(message);
6702
- /**
6716
+ /** {zh}
6703
6717
  * @brief 错误码。
6704
6718
  */
6705
6719
  /** {en}
6706
- * @brief The error code.
6720
+ * @brief Error code.
6707
6721
  */
6708
6722
  __publicField(this, "errorCode");
6709
6723
  /** {zh}
@@ -8478,7 +8492,7 @@ var __publicField = (obj, key, value) => {
8478
8492
  }
8479
8493
  this.on(DURATION_CHANGE, function() {
8480
8494
  var player2 = _this2.player, config2 = _this2.config;
8481
- if (player2.duration * 1e3 < config2.moveDuration) {
8495
+ if (player2.duration > 0 && player2.duration * 1e3 < config2.moveDuration) {
8482
8496
  config2.moveDuration = player2.duration * 1e3;
8483
8497
  }
8484
8498
  });
@@ -8792,10 +8806,13 @@ var __publicField = (obj, key, value) => {
8792
8806
  }, {
8793
8807
  key: "updateBrightness",
8794
8808
  value: function updateBrightness(percent) {
8809
+ var pos = this.pos, config = this.config, xgMask = this.xgMask;
8810
+ if (!config.darkness) {
8811
+ return;
8812
+ }
8795
8813
  if (this.player.rotateDeg) {
8796
8814
  percent = -percent;
8797
8815
  }
8798
- var pos = this.pos, config = this.config, xgMask = this.xgMask;
8799
8816
  var light = pos.light + 0.8 * percent;
8800
8817
  light = light > config.maxDarkness ? config.maxDarkness : light < 0 ? 0 : light;
8801
8818
  if (xgMask) {
@@ -8856,12 +8873,12 @@ var __publicField = (obj, key, value) => {
8856
8873
  }, {
8857
8874
  key: "disableGesture",
8858
8875
  value: function disableGesture() {
8859
- this.config.disableGesture = false;
8876
+ this.config.disableGesture = true;
8860
8877
  }
8861
8878
  }, {
8862
8879
  key: "enableGesture",
8863
8880
  value: function enableGesture() {
8864
- this.config.disableGesture = true;
8881
+ this.config.disableGesture = false;
8865
8882
  }
8866
8883
  }, {
8867
8884
  key: "destroy",
@@ -9730,7 +9747,7 @@ var __publicField = (obj, key, value) => {
9730
9747
  }, {
9731
9748
  key: "toggleFullScreen",
9732
9749
  value: function toggleFullScreen(e) {
9733
- if (e) {
9750
+ if (e instanceof Event) {
9734
9751
  e.preventDefault();
9735
9752
  e.stopPropagation();
9736
9753
  }
@@ -10413,7 +10430,7 @@ var __publicField = (obj, key, value) => {
10413
10430
  key: "isPIPAvailable",
10414
10431
  value: function isPIPAvailable() {
10415
10432
  var video = this.player.media;
10416
- var _isEnabled = util.typeOf(document.pictureInPictureEnabled) === "Boolean" ? document.pictureInPictureEnabled : true;
10433
+ var _isEnabled = util.typeOf(document.pictureInPictureEnabled) === "Boolean" ? document.pictureInPictureEnabled : false;
10417
10434
  return _isEnabled && (util.typeOf(video.disablePictureInPicture) === "Boolean" && !video.disablePictureInPicture || video.webkitSupportsPresentationMode && util.typeOf(video.webkitSetPresentationMode) === "Function") || this.isDocPIPAvailable();
10418
10435
  }
10419
10436
  }, {
@@ -13415,28 +13432,33 @@ var __publicField = (obj, key, value) => {
13415
13432
  useCssFullscreen: false
13416
13433
  }
13417
13434
  };
13418
- const transformOption = (options) => {
13419
- const { autoplay: autoplay2, ...rest } = options;
13420
- const xgOptions = rest;
13421
- if (xgOptions.poster) {
13422
- xgOptions.poster = escapeHtml(xgOptions.poster);
13423
- }
13424
- xgOptions.icons = {
13425
- ...DEFAULT_ICONS,
13426
- ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13427
- };
13428
- xgOptions.autoplay = Boolean(autoplay2);
13429
- if (autoplay2 && typeof autoplay2 !== "boolean") {
13430
- xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13431
- xgOptions.videoAttributes = {
13432
- ...xgOptions.videoAttributes ?? {},
13433
- muted: autoplay2 == null ? void 0 : autoplay2.muted
13435
+ const transformOption = (
13436
+ /** {zh}
13437
+ * @param options 更多配置信息。
13438
+ */
13439
+ (options) => {
13440
+ const { autoplay: autoplay2, ...rest } = options;
13441
+ const xgOptions = rest;
13442
+ if (xgOptions.poster) {
13443
+ xgOptions.poster = escapeHtml(xgOptions.poster);
13444
+ }
13445
+ xgOptions.icons = {
13446
+ ...DEFAULT_ICONS,
13447
+ ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13434
13448
  };
13435
- xgOptions.autoplayPlugin = autoplay2;
13449
+ xgOptions.autoplay = Boolean(autoplay2);
13450
+ if (autoplay2 && typeof autoplay2 !== "boolean") {
13451
+ xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13452
+ xgOptions.videoAttributes = {
13453
+ ...xgOptions.videoAttributes ?? {},
13454
+ muted: autoplay2 == null ? void 0 : autoplay2.muted
13455
+ };
13456
+ xgOptions.autoplayPlugin = autoplay2;
13457
+ }
13458
+ delete xgOptions.i18n;
13459
+ return xgOptions;
13436
13460
  }
13437
- delete xgOptions.i18n;
13438
- return xgOptions;
13439
- };
13461
+ );
13440
13462
  class VePlayerBase {
13441
13463
  /** {zh}
13442
13464
  * @hidden
@@ -13456,7 +13478,9 @@ var __publicField = (obj, key, value) => {
13456
13478
  this._sourceManager = options.sourceManager;
13457
13479
  this._preparePlugins = options.preparePlugins;
13458
13480
  this._previousPrepareResult = options.prepareResult;
13459
- this._i18nManager = options.i18nManager ?? new VeI18n({ i18n: options.i18n });
13481
+ this._i18nManager = options.i18nManager ?? new VeI18n({
13482
+ i18n: options.i18n
13483
+ });
13460
13484
  const xgOptions = transformOption({
13461
13485
  ...options,
13462
13486
  ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
@@ -13651,9 +13675,14 @@ var __publicField = (obj, key, value) => {
13651
13675
  /** {zh}
13652
13676
  * 获取播放器版本号
13653
13677
  * @returns
13678
+ * @brief
13679
+ * 获取播放器 SDK 版本号。
13680
+ */
13681
+ /** {en}
13682
+ * @brief Retrieve the player SDK version number.
13654
13683
  */
13655
13684
  get playerVersion() {
13656
- return "2.5.0-rc.1";
13685
+ return "2.6.0-rc.0";
13657
13686
  }
13658
13687
  /** {zh}
13659
13688
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -13801,8 +13830,8 @@ var __publicField = (obj, key, value) => {
13801
13830
  }
13802
13831
  /** {zh}
13803
13832
  * @brief 调用此方法切换拉流地址、线路、清晰度。
13804
- * @param target 目标地址,可以是播放地址,也可以是线路和清晰度
13805
- * @param options 更多配置信息
13833
+ * @param target 目标地址,可以是播放地址,也可以是线路和清晰度。
13834
+ * @param options 更多配置信息。
13806
13835
  */
13807
13836
  /** {en}
13808
13837
  * @brief Switches the pull stream address, playback source, or resolution.
@@ -13813,7 +13842,9 @@ var __publicField = (obj, key, value) => {
13813
13842
  var _a, _b;
13814
13843
  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) {
13815
13844
  this._sourceManager.updateSources(target);
13816
- await this._switchUrl(target, { seamless: options == null ? void 0 : options.seamless });
13845
+ await this._switchUrl(target, {
13846
+ seamless: options == null ? void 0 : options.seamless
13847
+ });
13817
13848
  return this._sourceManager.definition;
13818
13849
  }
13819
13850
  const targetDefinition = this._sourceManager.find(target, options);
@@ -13840,16 +13871,15 @@ var __publicField = (obj, key, value) => {
13840
13871
  return this._switch(sourceManager.definition);
13841
13872
  }
13842
13873
  // TODO: 等西瓜播放器完善错误码后增加函数重载以提供更好的类型
13843
- /**
13844
13874
  /** {zh}
13845
13875
  * @brief 调用此方法监听指定事件,事件处理函数只执行一次。
13846
13876
  * @param event 表示事件的名称。
13847
13877
  * @param callback 表示事件的回调函数。
13848
13878
  */
13849
13879
  /** {en}
13850
- * @brief Add a one-time listener function for the specified event.
13851
- * @param event The event name.
13852
- * @param callback The callback function for the event.
13880
+ * @brief Call this method to listen for the specified event. The event handler is executed only once.
13881
+ * @param event The name representing the event.
13882
+ * @param callback Callback functions representing events.
13853
13883
  */
13854
13884
  once(event, callback) {
13855
13885
  var _a;
@@ -14000,10 +14030,14 @@ var __publicField = (obj, key, value) => {
14000
14030
  return this._player.blur(data);
14001
14031
  }
14002
14032
  /** {zh}
14003
- * @brief 判断浏览器是否支持播放格式
14004
- * @param type 播放格式
14033
+ * @brief 判断浏览器是否支持播放格式。
14034
+ * @param type 播放格式。
14005
14035
  * @returns
14006
14036
  */
14037
+ /** {en}
14038
+ * @brief Determine whether the browser supports the playback format.
14039
+ * @param type The playback format.
14040
+ */
14007
14041
  canPlayType(type) {
14008
14042
  return this._player.canPlayType(type);
14009
14043
  }
@@ -14075,7 +14109,7 @@ var __publicField = (obj, key, value) => {
14075
14109
  }
14076
14110
  /** {zh}
14077
14111
  * @brief 调用此接口显示指定插件图标。
14078
- * @param pluginNames 插件名称
14112
+ * @param pluginNames 插件名称。
14079
14113
  */
14080
14114
  /** {en}
14081
14115
  * @brief Displays the icon of a specified plugin.
@@ -14096,7 +14130,7 @@ var __publicField = (obj, key, value) => {
14096
14130
  }
14097
14131
  /** {zh}
14098
14132
  * @brief 调用此接口隐藏指定插件图标。
14099
- * @param pluginNames 插件名称
14133
+ * @param pluginNames 插件名称。
14100
14134
  */
14101
14135
  /** {en}
14102
14136
  * @brief Hides the icon of a specified plugin.
@@ -14168,7 +14202,14 @@ var __publicField = (obj, key, value) => {
14168
14202
  this._player.once("canplay", () => {
14169
14203
  this._sourceManager.resetFallback();
14170
14204
  });
14171
- this.emit(Events.FALLBACK, { from: { url: preUrl }, to: { url } });
14205
+ this.emit(Events.FALLBACK, {
14206
+ from: {
14207
+ url: preUrl
14208
+ },
14209
+ to: {
14210
+ url
14211
+ }
14212
+ });
14172
14213
  this._switchUrl(url);
14173
14214
  }
14174
14215
  // eslint-disable-next-line @typescript-eslint/no-explicit-any