@volcengine/veplayer 2.5.0-rc.1 → 2.5.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.2";
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
  }, {
@@ -12792,11 +12809,15 @@ var __publicField = (obj, key, value) => {
12792
12809
  const { XGVideoPlugin } = await load(DynamicModule.PluginXgvideo);
12793
12810
  return XGVideoPlugin == null ? void 0 : XGVideoPlugin.isSupported();
12794
12811
  }
12812
+ function isMMSSupported() {
12813
+ return typeof ManagedMediaSource !== "undefined";
12814
+ }
12795
12815
  ({
12796
12816
  ...util,
12797
12817
  getStreamType,
12798
12818
  isMseSupported,
12799
12819
  isSoftDecodeSupported,
12820
+ isMMSSupported,
12800
12821
  appendSearchParams,
12801
12822
  getUrlObject
12802
12823
  });
@@ -13009,7 +13030,6 @@ var __publicField = (obj, key, value) => {
13009
13030
  }
13010
13031
  // 有音量修改,取消静音
13011
13032
  handleVolumechange() {
13012
- this._state.mode = this.player.muted ? 1 : 0;
13013
13033
  if (!this._state.showUnmuteBt)
13014
13034
  return;
13015
13035
  this._state.showUnmuteBt = false;
@@ -13415,28 +13435,33 @@ var __publicField = (obj, key, value) => {
13415
13435
  useCssFullscreen: false
13416
13436
  }
13417
13437
  };
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
13438
+ const transformOption = (
13439
+ /** {zh}
13440
+ * @param options 更多配置信息。
13441
+ */
13442
+ (options) => {
13443
+ const { autoplay: autoplay2, ...rest } = options;
13444
+ const xgOptions = rest;
13445
+ if (xgOptions.poster) {
13446
+ xgOptions.poster = escapeHtml(xgOptions.poster);
13447
+ }
13448
+ xgOptions.icons = {
13449
+ ...DEFAULT_ICONS,
13450
+ ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13434
13451
  };
13435
- xgOptions.autoplayPlugin = autoplay2;
13452
+ xgOptions.autoplay = Boolean(autoplay2);
13453
+ if (autoplay2 && typeof autoplay2 !== "boolean") {
13454
+ xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13455
+ xgOptions.videoAttributes = {
13456
+ ...xgOptions.videoAttributes ?? {},
13457
+ muted: autoplay2 == null ? void 0 : autoplay2.muted
13458
+ };
13459
+ xgOptions.autoplayPlugin = autoplay2;
13460
+ }
13461
+ delete xgOptions.i18n;
13462
+ return xgOptions;
13436
13463
  }
13437
- delete xgOptions.i18n;
13438
- return xgOptions;
13439
- };
13464
+ );
13440
13465
  class VePlayerBase {
13441
13466
  /** {zh}
13442
13467
  * @hidden
@@ -13456,7 +13481,9 @@ var __publicField = (obj, key, value) => {
13456
13481
  this._sourceManager = options.sourceManager;
13457
13482
  this._preparePlugins = options.preparePlugins;
13458
13483
  this._previousPrepareResult = options.prepareResult;
13459
- this._i18nManager = options.i18nManager ?? new VeI18n({ i18n: options.i18n });
13484
+ this._i18nManager = options.i18nManager ?? new VeI18n({
13485
+ i18n: options.i18n
13486
+ });
13460
13487
  const xgOptions = transformOption({
13461
13488
  ...options,
13462
13489
  ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
@@ -13651,9 +13678,14 @@ var __publicField = (obj, key, value) => {
13651
13678
  /** {zh}
13652
13679
  * 获取播放器版本号
13653
13680
  * @returns
13681
+ * @brief
13682
+ * 获取播放器 SDK 版本号。
13683
+ */
13684
+ /** {en}
13685
+ * @brief Retrieve the player SDK version number.
13654
13686
  */
13655
13687
  get playerVersion() {
13656
- return "2.5.0-rc.1";
13688
+ return "2.5.0";
13657
13689
  }
13658
13690
  /** {zh}
13659
13691
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -13801,8 +13833,8 @@ var __publicField = (obj, key, value) => {
13801
13833
  }
13802
13834
  /** {zh}
13803
13835
  * @brief 调用此方法切换拉流地址、线路、清晰度。
13804
- * @param target 目标地址,可以是播放地址,也可以是线路和清晰度
13805
- * @param options 更多配置信息
13836
+ * @param target 目标地址,可以是播放地址,也可以是线路和清晰度。
13837
+ * @param options 更多配置信息。
13806
13838
  */
13807
13839
  /** {en}
13808
13840
  * @brief Switches the pull stream address, playback source, or resolution.
@@ -13813,7 +13845,9 @@ var __publicField = (obj, key, value) => {
13813
13845
  var _a, _b;
13814
13846
  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
13847
  this._sourceManager.updateSources(target);
13816
- await this._switchUrl(target, { seamless: options == null ? void 0 : options.seamless });
13848
+ await this._switchUrl(target, {
13849
+ seamless: options == null ? void 0 : options.seamless
13850
+ });
13817
13851
  return this._sourceManager.definition;
13818
13852
  }
13819
13853
  const targetDefinition = this._sourceManager.find(target, options);
@@ -13840,16 +13874,15 @@ var __publicField = (obj, key, value) => {
13840
13874
  return this._switch(sourceManager.definition);
13841
13875
  }
13842
13876
  // TODO: 等西瓜播放器完善错误码后增加函数重载以提供更好的类型
13843
- /**
13844
13877
  /** {zh}
13845
13878
  * @brief 调用此方法监听指定事件,事件处理函数只执行一次。
13846
13879
  * @param event 表示事件的名称。
13847
13880
  * @param callback 表示事件的回调函数。
13848
13881
  */
13849
13882
  /** {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.
13883
+ * @brief Call this method to listen for the specified event. The event handler is executed only once.
13884
+ * @param event The name representing the event.
13885
+ * @param callback Callback functions representing events.
13853
13886
  */
13854
13887
  once(event, callback) {
13855
13888
  var _a;
@@ -14000,10 +14033,14 @@ var __publicField = (obj, key, value) => {
14000
14033
  return this._player.blur(data);
14001
14034
  }
14002
14035
  /** {zh}
14003
- * @brief 判断浏览器是否支持播放格式
14004
- * @param type 播放格式
14036
+ * @brief 判断浏览器是否支持播放格式。
14037
+ * @param type 播放格式。
14005
14038
  * @returns
14006
14039
  */
14040
+ /** {en}
14041
+ * @brief Determine whether the browser supports the playback format.
14042
+ * @param type The playback format.
14043
+ */
14007
14044
  canPlayType(type) {
14008
14045
  return this._player.canPlayType(type);
14009
14046
  }
@@ -14075,7 +14112,7 @@ var __publicField = (obj, key, value) => {
14075
14112
  }
14076
14113
  /** {zh}
14077
14114
  * @brief 调用此接口显示指定插件图标。
14078
- * @param pluginNames 插件名称
14115
+ * @param pluginNames 插件名称。
14079
14116
  */
14080
14117
  /** {en}
14081
14118
  * @brief Displays the icon of a specified plugin.
@@ -14096,7 +14133,7 @@ var __publicField = (obj, key, value) => {
14096
14133
  }
14097
14134
  /** {zh}
14098
14135
  * @brief 调用此接口隐藏指定插件图标。
14099
- * @param pluginNames 插件名称
14136
+ * @param pluginNames 插件名称。
14100
14137
  */
14101
14138
  /** {en}
14102
14139
  * @brief Hides the icon of a specified plugin.
@@ -14168,7 +14205,14 @@ var __publicField = (obj, key, value) => {
14168
14205
  this._player.once("canplay", () => {
14169
14206
  this._sourceManager.resetFallback();
14170
14207
  });
14171
- this.emit(Events.FALLBACK, { from: { url: preUrl }, to: { url } });
14208
+ this.emit(Events.FALLBACK, {
14209
+ from: {
14210
+ url: preUrl
14211
+ },
14212
+ to: {
14213
+ url
14214
+ }
14215
+ });
14172
14216
  this._switchUrl(url);
14173
14217
  }
14174
14218
  // eslint-disable-next-line @typescript-eslint/no-explicit-any