@volcengine/veplayer 2.5.0-rc.1 → 2.5.1-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.
@@ -1452,7 +1452,7 @@ var sniffer = {
1452
1452
  }
1453
1453
  }
1454
1454
  };
1455
- var version = "3.0.20-alpha.4";
1455
+ var version = "3.0.21-rc.5";
1456
1456
  var ERROR_TYPE_MAP = {
1457
1457
  1: "media",
1458
1458
  2: "media",
@@ -1908,7 +1908,7 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
1908
1908
  var _e = this.media.error || error2;
1909
1909
  var type = _e.code ? ERROR_TYPE_MAP[_e.code] : "other";
1910
1910
  var message = _e.message;
1911
- if (!this.media.currentSrc) {
1911
+ if (!(this.media.currentSrc || this.media.srcObject)) {
1912
1912
  message = "empty_src";
1913
1913
  _e = {
1914
1914
  code: 6,
@@ -2803,6 +2803,18 @@ var BasePlugin = /* @__PURE__ */ function() {
2803
2803
  }
2804
2804
  }
2805
2805
  }
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
+ }
2806
2818
  }, {
2807
2819
  key: "defaultConfig",
2808
2820
  get: function get() {
@@ -3448,7 +3460,7 @@ var ResizeObserver = /* @__PURE__ */ function() {
3448
3460
  if (!this.observer) {
3449
3461
  return;
3450
3462
  }
3451
- this.observer && this.observer.observe(target);
3463
+ this.observer.observe(target);
3452
3464
  var _pid = target.getAttribute(PLATER_ID);
3453
3465
  var __handlers = this.__handlers;
3454
3466
  var index = -1;
@@ -3477,16 +3489,17 @@ var ResizeObserver = /* @__PURE__ */ function() {
3477
3489
  }
3478
3490
  });
3479
3491
  try {
3480
- this.observer && this.observer.unobserve(target);
3492
+ var _this$observer;
3493
+ (_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.unobserve(target);
3481
3494
  } catch (e) {
3482
3495
  }
3483
- this.observer && this.observer.unobserve(target);
3484
3496
  i > -1 && this.__handlers.splice(i, 1);
3485
3497
  }
3486
3498
  }, {
3487
3499
  key: "destroyObserver",
3488
3500
  value: function destroyObserver() {
3489
- this.observer && this.observer.disconnect();
3501
+ var _this$observer2;
3502
+ (_this$observer2 = this.observer) === null || _this$observer2 === void 0 ? void 0 : _this$observer2.disconnect();
3490
3503
  this.observer = null;
3491
3504
  this.__handlers = null;
3492
3505
  }
@@ -3518,7 +3531,8 @@ function addObserver(target, handler) {
3518
3531
  return resizeObserver;
3519
3532
  }
3520
3533
  function unObserver(target, handler) {
3521
- resizeObserver.unObserver(target, handler);
3534
+ var _resizeObserver;
3535
+ (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.unObserver(target, handler);
3522
3536
  }
3523
3537
  var pluginsManager = {
3524
3538
  pluginGroup: {},
@@ -4108,6 +4122,10 @@ var Controls = /* @__PURE__ */ function(_Plugin) {
4108
4122
  this.unbind("mouseenter", this.onMouseEnter);
4109
4123
  this.unbind("mouseleave", this.onMouseLeave);
4110
4124
  }
4125
+ this.left = null;
4126
+ this.center = null;
4127
+ this.right = null;
4128
+ this.innerRoot = null;
4111
4129
  }
4112
4130
  }, {
4113
4131
  key: "render",
@@ -5110,7 +5128,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5110
5128
  if (!url) {
5111
5129
  url = _this8.url || _this8.config.url;
5112
5130
  }
5113
- var _furl = _this8._preProcessUrl(url);
5131
+ var _furl = _this8.preProcessUrl(url);
5114
5132
  var ret = _this8._startInit(_furl.url);
5115
5133
  return ret;
5116
5134
  }).catch(function(e) {
@@ -5128,7 +5146,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5128
5146
  if (util.typeOf(url) === "Object") {
5129
5147
  _src = url.url;
5130
5148
  }
5131
- _src = this._preProcessUrl(_src).url;
5149
+ _src = this.preProcessUrl(_src).url;
5132
5150
  var curTime = this.currentTime;
5133
5151
  this.__startTime = curTime;
5134
5152
  var isPaused = this.paused && !this.isError;
@@ -5469,7 +5487,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5469
5487
  runHooks(this, "retry", function() {
5470
5488
  var cur = _this20.currentTime;
5471
5489
  var url = _this20.config.url;
5472
- var _srcRet = !util.isMSE(_this20.media) ? _this20._preProcessUrl(url) : {
5490
+ var _srcRet = !util.isMSE(_this20.media) ? _this20.preProcessUrl(url) : {
5473
5491
  url
5474
5492
  };
5475
5493
  _this20.src = _srcRet.url;
@@ -6125,11 +6143,11 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6125
6143
  this._state = newState;
6126
6144
  }
6127
6145
  }, {
6128
- key: "_preProcessUrl",
6129
- value: function _preProcessUrl(url, ext) {
6130
- 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;
6131
6149
  var processUrlOptions = Object.assign({}, preProcessUrlOptions, ext);
6132
- return !util.isBlob(url) && typeof preProcessUrl === "function" ? preProcessUrl(url, processUrlOptions) : {
6150
+ return !util.isBlob(url) && typeof preProcessUrl2 === "function" ? preProcessUrl2(url, processUrlOptions) : {
6133
6151
  url
6134
6152
  };
6135
6153
  }
@@ -6695,11 +6713,11 @@ class VeError extends Error {
6695
6713
  } : error2;
6696
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"));
6697
6715
  super(message);
6698
- /**
6716
+ /** {zh}
6699
6717
  * @brief 错误码。
6700
6718
  */
6701
6719
  /** {en}
6702
- * @brief The error code.
6720
+ * @brief Error code.
6703
6721
  */
6704
6722
  __publicField(this, "errorCode");
6705
6723
  /** {zh}
@@ -8474,7 +8492,7 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8474
8492
  }
8475
8493
  this.on(DURATION_CHANGE, function() {
8476
8494
  var player2 = _this2.player, config2 = _this2.config;
8477
- if (player2.duration * 1e3 < config2.moveDuration) {
8495
+ if (player2.duration > 0 && player2.duration * 1e3 < config2.moveDuration) {
8478
8496
  config2.moveDuration = player2.duration * 1e3;
8479
8497
  }
8480
8498
  });
@@ -8788,10 +8806,13 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8788
8806
  }, {
8789
8807
  key: "updateBrightness",
8790
8808
  value: function updateBrightness(percent) {
8809
+ var pos = this.pos, config = this.config, xgMask = this.xgMask;
8810
+ if (!config.darkness) {
8811
+ return;
8812
+ }
8791
8813
  if (this.player.rotateDeg) {
8792
8814
  percent = -percent;
8793
8815
  }
8794
- var pos = this.pos, config = this.config, xgMask = this.xgMask;
8795
8816
  var light = pos.light + 0.8 * percent;
8796
8817
  light = light > config.maxDarkness ? config.maxDarkness : light < 0 ? 0 : light;
8797
8818
  if (xgMask) {
@@ -8852,12 +8873,12 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8852
8873
  }, {
8853
8874
  key: "disableGesture",
8854
8875
  value: function disableGesture() {
8855
- this.config.disableGesture = false;
8876
+ this.config.disableGesture = true;
8856
8877
  }
8857
8878
  }, {
8858
8879
  key: "enableGesture",
8859
8880
  value: function enableGesture() {
8860
- this.config.disableGesture = true;
8881
+ this.config.disableGesture = false;
8861
8882
  }
8862
8883
  }, {
8863
8884
  key: "destroy",
@@ -9726,7 +9747,7 @@ var Fullscreen = /* @__PURE__ */ function(_IconPlugin) {
9726
9747
  }, {
9727
9748
  key: "toggleFullScreen",
9728
9749
  value: function toggleFullScreen(e) {
9729
- if (e) {
9750
+ if (e instanceof Event) {
9730
9751
  e.preventDefault();
9731
9752
  e.stopPropagation();
9732
9753
  }
@@ -10409,7 +10430,7 @@ var PIP = /* @__PURE__ */ function(_IconPlugin) {
10409
10430
  key: "isPIPAvailable",
10410
10431
  value: function isPIPAvailable() {
10411
10432
  var video = this.player.media;
10412
- var _isEnabled = util.typeOf(document.pictureInPictureEnabled) === "Boolean" ? document.pictureInPictureEnabled : true;
10433
+ var _isEnabled = util.typeOf(document.pictureInPictureEnabled) === "Boolean" ? document.pictureInPictureEnabled : false;
10413
10434
  return _isEnabled && (util.typeOf(video.disablePictureInPicture) === "Boolean" && !video.disablePictureInPicture || video.webkitSupportsPresentationMode && util.typeOf(video.webkitSetPresentationMode) === "Function") || this.isDocPIPAvailable();
10414
10435
  }
10415
10436
  }, {
@@ -12750,6 +12771,13 @@ const getUrlObject = (url) => {
12750
12771
  return;
12751
12772
  }
12752
12773
  };
12774
+ const H264_MIME = 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
12775
+ const H265_MIME = [
12776
+ 'video/mp4;codecs="hev1.1.6.L120.90"',
12777
+ 'video/mp4;codecs="hev1.2.4.L120.90"',
12778
+ 'video/mp4;codecs="hev1.3.E.L120.90"',
12779
+ 'video/mp4;codecs="hev1.4.10.L120.90"'
12780
+ ];
12753
12781
  function isType(suffix) {
12754
12782
  return function(url) {
12755
12783
  return url == null ? void 0 : url.split("?")[0].toLowerCase().includes(suffix);
@@ -12782,17 +12810,35 @@ function isMseSupported(codec = Codec.H264) {
12782
12810
  if (codec === Codec.H265) {
12783
12811
  return sniffer.isHevcSupported();
12784
12812
  }
12785
- return sniffer.isMSESupport();
12813
+ if (codec === Codec.H264) {
12814
+ return sniffer.isMSESupport();
12815
+ }
12816
+ return sniffer.isMSESupport(codec);
12786
12817
  }
12787
12818
  async function isSoftDecodeSupported() {
12788
12819
  const { XGVideoPlugin } = await load(DynamicModule.PluginXgvideo);
12789
12820
  return XGVideoPlugin == null ? void 0 : XGVideoPlugin.isSupported();
12790
12821
  }
12822
+ function isMMSSupported(codec = Codec.H264) {
12823
+ if (typeof window.ManagedMediaSource === "undefined") {
12824
+ return false;
12825
+ }
12826
+ if (codec === Codec.H264) {
12827
+ return window.ManagedMediaSource.isTypeSupported(H264_MIME);
12828
+ }
12829
+ if (codec === Codec.H265) {
12830
+ return H265_MIME.some((mine) => {
12831
+ return window.ManagedMediaSource.isTypeSupported(mine);
12832
+ });
12833
+ }
12834
+ return window.ManagedMediaSource.isTypeSupported(codec);
12835
+ }
12791
12836
  ({
12792
12837
  ...util,
12793
12838
  getStreamType,
12794
12839
  isMseSupported,
12795
12840
  isSoftDecodeSupported,
12841
+ isMMSSupported,
12796
12842
  appendSearchParams,
12797
12843
  getUrlObject
12798
12844
  });
@@ -13005,7 +13051,6 @@ class Autoplay extends Plugin {
13005
13051
  }
13006
13052
  // 有音量修改,取消静音
13007
13053
  handleVolumechange() {
13008
- this._state.mode = this.player.muted ? 1 : 0;
13009
13054
  if (!this._state.showUnmuteBt)
13010
13055
  return;
13011
13056
  this._state.showUnmuteBt = false;
@@ -13411,28 +13456,33 @@ const DEFAULT_OPTIONS = {
13411
13456
  useCssFullscreen: false
13412
13457
  }
13413
13458
  };
13414
- const transformOption = (options) => {
13415
- const { autoplay: autoplay2, ...rest } = options;
13416
- const xgOptions = rest;
13417
- if (xgOptions.poster) {
13418
- xgOptions.poster = escapeHtml(xgOptions.poster);
13419
- }
13420
- xgOptions.icons = {
13421
- ...DEFAULT_ICONS,
13422
- ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13423
- };
13424
- xgOptions.autoplay = Boolean(autoplay2);
13425
- if (autoplay2 && typeof autoplay2 !== "boolean") {
13426
- xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13427
- xgOptions.videoAttributes = {
13428
- ...xgOptions.videoAttributes ?? {},
13429
- muted: autoplay2 == null ? void 0 : autoplay2.muted
13459
+ const transformOption = (
13460
+ /** {zh}
13461
+ * @param options 更多配置信息。
13462
+ */
13463
+ (options) => {
13464
+ const { autoplay: autoplay2, ...rest } = options;
13465
+ const xgOptions = rest;
13466
+ if (xgOptions.poster) {
13467
+ xgOptions.poster = escapeHtml(xgOptions.poster);
13468
+ }
13469
+ xgOptions.icons = {
13470
+ ...DEFAULT_ICONS,
13471
+ ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13430
13472
  };
13431
- xgOptions.autoplayPlugin = autoplay2;
13473
+ xgOptions.autoplay = Boolean(autoplay2);
13474
+ if (autoplay2 && typeof autoplay2 !== "boolean") {
13475
+ xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13476
+ xgOptions.videoAttributes = {
13477
+ ...xgOptions.videoAttributes ?? {},
13478
+ muted: autoplay2 == null ? void 0 : autoplay2.muted
13479
+ };
13480
+ xgOptions.autoplayPlugin = autoplay2;
13481
+ }
13482
+ delete xgOptions.i18n;
13483
+ return xgOptions;
13432
13484
  }
13433
- delete xgOptions.i18n;
13434
- return xgOptions;
13435
- };
13485
+ );
13436
13486
  class VePlayerBase {
13437
13487
  /** {zh}
13438
13488
  * @hidden
@@ -13452,7 +13502,9 @@ class VePlayerBase {
13452
13502
  this._sourceManager = options.sourceManager;
13453
13503
  this._preparePlugins = options.preparePlugins;
13454
13504
  this._previousPrepareResult = options.prepareResult;
13455
- this._i18nManager = options.i18nManager ?? new VeI18n({ i18n: options.i18n });
13505
+ this._i18nManager = options.i18nManager ?? new VeI18n({
13506
+ i18n: options.i18n
13507
+ });
13456
13508
  const xgOptions = transformOption({
13457
13509
  ...options,
13458
13510
  ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
@@ -13647,9 +13699,14 @@ class VePlayerBase {
13647
13699
  /** {zh}
13648
13700
  * 获取播放器版本号
13649
13701
  * @returns
13702
+ * @brief
13703
+ * 获取播放器 SDK 版本号。
13704
+ */
13705
+ /** {en}
13706
+ * @brief Retrieve the player SDK version number.
13650
13707
  */
13651
13708
  get playerVersion() {
13652
- return "2.5.0-rc.1";
13709
+ return "2.5.1-rc.0";
13653
13710
  }
13654
13711
  /** {zh}
13655
13712
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -13797,8 +13854,8 @@ class VePlayerBase {
13797
13854
  }
13798
13855
  /** {zh}
13799
13856
  * @brief 调用此方法切换拉流地址、线路、清晰度。
13800
- * @param target 目标地址,可以是播放地址,也可以是线路和清晰度
13801
- * @param options 更多配置信息
13857
+ * @param target 目标地址,可以是播放地址,也可以是线路和清晰度。
13858
+ * @param options 更多配置信息。
13802
13859
  */
13803
13860
  /** {en}
13804
13861
  * @brief Switches the pull stream address, playback source, or resolution.
@@ -13809,7 +13866,9 @@ class VePlayerBase {
13809
13866
  var _a, _b;
13810
13867
  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) {
13811
13868
  this._sourceManager.updateSources(target);
13812
- await this._switchUrl(target, { seamless: options == null ? void 0 : options.seamless });
13869
+ await this._switchUrl(target, {
13870
+ seamless: options == null ? void 0 : options.seamless
13871
+ });
13813
13872
  return this._sourceManager.definition;
13814
13873
  }
13815
13874
  const targetDefinition = this._sourceManager.find(target, options);
@@ -13836,16 +13895,15 @@ class VePlayerBase {
13836
13895
  return this._switch(sourceManager.definition);
13837
13896
  }
13838
13897
  // TODO: 等西瓜播放器完善错误码后增加函数重载以提供更好的类型
13839
- /**
13840
13898
  /** {zh}
13841
13899
  * @brief 调用此方法监听指定事件,事件处理函数只执行一次。
13842
13900
  * @param event 表示事件的名称。
13843
13901
  * @param callback 表示事件的回调函数。
13844
13902
  */
13845
13903
  /** {en}
13846
- * @brief Add a one-time listener function for the specified event.
13847
- * @param event The event name.
13848
- * @param callback The callback function for the event.
13904
+ * @brief Call this method to listen for the specified event. The event handler is executed only once.
13905
+ * @param event The name representing the event.
13906
+ * @param callback Callback functions representing events.
13849
13907
  */
13850
13908
  once(event, callback) {
13851
13909
  var _a;
@@ -13996,10 +14054,14 @@ class VePlayerBase {
13996
14054
  return this._player.blur(data);
13997
14055
  }
13998
14056
  /** {zh}
13999
- * @brief 判断浏览器是否支持播放格式
14000
- * @param type 播放格式
14057
+ * @brief 判断浏览器是否支持播放格式。
14058
+ * @param type 播放格式。
14001
14059
  * @returns
14002
14060
  */
14061
+ /** {en}
14062
+ * @brief Determine whether the browser supports the playback format.
14063
+ * @param type The playback format.
14064
+ */
14003
14065
  canPlayType(type) {
14004
14066
  return this._player.canPlayType(type);
14005
14067
  }
@@ -14071,7 +14133,7 @@ class VePlayerBase {
14071
14133
  }
14072
14134
  /** {zh}
14073
14135
  * @brief 调用此接口显示指定插件图标。
14074
- * @param pluginNames 插件名称
14136
+ * @param pluginNames 插件名称。
14075
14137
  */
14076
14138
  /** {en}
14077
14139
  * @brief Displays the icon of a specified plugin.
@@ -14092,7 +14154,7 @@ class VePlayerBase {
14092
14154
  }
14093
14155
  /** {zh}
14094
14156
  * @brief 调用此接口隐藏指定插件图标。
14095
- * @param pluginNames 插件名称
14157
+ * @param pluginNames 插件名称。
14096
14158
  */
14097
14159
  /** {en}
14098
14160
  * @brief Hides the icon of a specified plugin.
@@ -14164,7 +14226,14 @@ class VePlayerBase {
14164
14226
  this._player.once("canplay", () => {
14165
14227
  this._sourceManager.resetFallback();
14166
14228
  });
14167
- this.emit(Events.FALLBACK, { from: { url: preUrl }, to: { url } });
14229
+ this.emit(Events.FALLBACK, {
14230
+ from: {
14231
+ url: preUrl
14232
+ },
14233
+ to: {
14234
+ url
14235
+ }
14236
+ });
14168
14237
  this._switchUrl(url);
14169
14238
  }
14170
14239
  // eslint-disable-next-line @typescript-eslint/no-explicit-any