@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.
@@ -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.5";
1460
1460
  var ERROR_TYPE_MAP = {
1461
1461
  1: "media",
1462
1462
  2: "media",
@@ -1912,7 +1912,7 @@ var __publicField = (obj, key, value) => {
1912
1912
  var _e = this.media.error || error2;
1913
1913
  var type = _e.code ? ERROR_TYPE_MAP[_e.code] : "other";
1914
1914
  var message = _e.message;
1915
- if (!this.media.currentSrc) {
1915
+ if (!(this.media.currentSrc || this.media.srcObject)) {
1916
1916
  message = "empty_src";
1917
1917
  _e = {
1918
1918
  code: 6,
@@ -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: {},
@@ -4112,6 +4126,10 @@ var __publicField = (obj, key, value) => {
4112
4126
  this.unbind("mouseenter", this.onMouseEnter);
4113
4127
  this.unbind("mouseleave", this.onMouseLeave);
4114
4128
  }
4129
+ this.left = null;
4130
+ this.center = null;
4131
+ this.right = null;
4132
+ this.innerRoot = null;
4115
4133
  }
4116
4134
  }, {
4117
4135
  key: "render",
@@ -5114,7 +5132,7 @@ var __publicField = (obj, key, value) => {
5114
5132
  if (!url) {
5115
5133
  url = _this8.url || _this8.config.url;
5116
5134
  }
5117
- var _furl = _this8._preProcessUrl(url);
5135
+ var _furl = _this8.preProcessUrl(url);
5118
5136
  var ret = _this8._startInit(_furl.url);
5119
5137
  return ret;
5120
5138
  }).catch(function(e) {
@@ -5132,7 +5150,7 @@ var __publicField = (obj, key, value) => {
5132
5150
  if (util.typeOf(url) === "Object") {
5133
5151
  _src = url.url;
5134
5152
  }
5135
- _src = this._preProcessUrl(_src).url;
5153
+ _src = this.preProcessUrl(_src).url;
5136
5154
  var curTime = this.currentTime;
5137
5155
  this.__startTime = curTime;
5138
5156
  var isPaused = this.paused && !this.isError;
@@ -5473,7 +5491,7 @@ var __publicField = (obj, key, value) => {
5473
5491
  runHooks(this, "retry", function() {
5474
5492
  var cur = _this20.currentTime;
5475
5493
  var url = _this20.config.url;
5476
- var _srcRet = !util.isMSE(_this20.media) ? _this20._preProcessUrl(url) : {
5494
+ var _srcRet = !util.isMSE(_this20.media) ? _this20.preProcessUrl(url) : {
5477
5495
  url
5478
5496
  };
5479
5497
  _this20.src = _srcRet.url;
@@ -6129,11 +6147,11 @@ var __publicField = (obj, key, value) => {
6129
6147
  this._state = newState;
6130
6148
  }
6131
6149
  }, {
6132
- key: "_preProcessUrl",
6133
- value: function _preProcessUrl(url, ext) {
6134
- var _this$config7 = this.config, preProcessUrl = _this$config7.preProcessUrl, preProcessUrlOptions = _this$config7.preProcessUrlOptions;
6150
+ key: "preProcessUrl",
6151
+ value: function preProcessUrl(url, ext) {
6152
+ var _this$config7 = this.config, preProcessUrl2 = _this$config7.preProcessUrl, preProcessUrlOptions = _this$config7.preProcessUrlOptions;
6135
6153
  var processUrlOptions = Object.assign({}, preProcessUrlOptions, ext);
6136
- return !util.isBlob(url) && typeof preProcessUrl === "function" ? preProcessUrl(url, processUrlOptions) : {
6154
+ return !util.isBlob(url) && typeof preProcessUrl2 === "function" ? preProcessUrl2(url, processUrlOptions) : {
6137
6155
  url
6138
6156
  };
6139
6157
  }
@@ -6699,11 +6717,11 @@ var __publicField = (obj, key, value) => {
6699
6717
  } : error2;
6700
6718
  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
6719
  super(message);
6702
- /**
6720
+ /** {zh}
6703
6721
  * @brief 错误码。
6704
6722
  */
6705
6723
  /** {en}
6706
- * @brief The error code.
6724
+ * @brief Error code.
6707
6725
  */
6708
6726
  __publicField(this, "errorCode");
6709
6727
  /** {zh}
@@ -8478,7 +8496,7 @@ var __publicField = (obj, key, value) => {
8478
8496
  }
8479
8497
  this.on(DURATION_CHANGE, function() {
8480
8498
  var player2 = _this2.player, config2 = _this2.config;
8481
- if (player2.duration * 1e3 < config2.moveDuration) {
8499
+ if (player2.duration > 0 && player2.duration * 1e3 < config2.moveDuration) {
8482
8500
  config2.moveDuration = player2.duration * 1e3;
8483
8501
  }
8484
8502
  });
@@ -8792,10 +8810,13 @@ var __publicField = (obj, key, value) => {
8792
8810
  }, {
8793
8811
  key: "updateBrightness",
8794
8812
  value: function updateBrightness(percent) {
8813
+ var pos = this.pos, config = this.config, xgMask = this.xgMask;
8814
+ if (!config.darkness) {
8815
+ return;
8816
+ }
8795
8817
  if (this.player.rotateDeg) {
8796
8818
  percent = -percent;
8797
8819
  }
8798
- var pos = this.pos, config = this.config, xgMask = this.xgMask;
8799
8820
  var light = pos.light + 0.8 * percent;
8800
8821
  light = light > config.maxDarkness ? config.maxDarkness : light < 0 ? 0 : light;
8801
8822
  if (xgMask) {
@@ -8856,12 +8877,12 @@ var __publicField = (obj, key, value) => {
8856
8877
  }, {
8857
8878
  key: "disableGesture",
8858
8879
  value: function disableGesture() {
8859
- this.config.disableGesture = false;
8880
+ this.config.disableGesture = true;
8860
8881
  }
8861
8882
  }, {
8862
8883
  key: "enableGesture",
8863
8884
  value: function enableGesture() {
8864
- this.config.disableGesture = true;
8885
+ this.config.disableGesture = false;
8865
8886
  }
8866
8887
  }, {
8867
8888
  key: "destroy",
@@ -9730,7 +9751,7 @@ var __publicField = (obj, key, value) => {
9730
9751
  }, {
9731
9752
  key: "toggleFullScreen",
9732
9753
  value: function toggleFullScreen(e) {
9733
- if (e) {
9754
+ if (e instanceof Event) {
9734
9755
  e.preventDefault();
9735
9756
  e.stopPropagation();
9736
9757
  }
@@ -10413,7 +10434,7 @@ var __publicField = (obj, key, value) => {
10413
10434
  key: "isPIPAvailable",
10414
10435
  value: function isPIPAvailable() {
10415
10436
  var video = this.player.media;
10416
- var _isEnabled = util.typeOf(document.pictureInPictureEnabled) === "Boolean" ? document.pictureInPictureEnabled : true;
10437
+ var _isEnabled = util.typeOf(document.pictureInPictureEnabled) === "Boolean" ? document.pictureInPictureEnabled : false;
10417
10438
  return _isEnabled && (util.typeOf(video.disablePictureInPicture) === "Boolean" && !video.disablePictureInPicture || video.webkitSupportsPresentationMode && util.typeOf(video.webkitSetPresentationMode) === "Function") || this.isDocPIPAvailable();
10418
10439
  }
10419
10440
  }, {
@@ -12754,6 +12775,13 @@ var __publicField = (obj, key, value) => {
12754
12775
  return;
12755
12776
  }
12756
12777
  };
12778
+ const H264_MIME = 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
12779
+ const H265_MIME = [
12780
+ 'video/mp4;codecs="hev1.1.6.L120.90"',
12781
+ 'video/mp4;codecs="hev1.2.4.L120.90"',
12782
+ 'video/mp4;codecs="hev1.3.E.L120.90"',
12783
+ 'video/mp4;codecs="hev1.4.10.L120.90"'
12784
+ ];
12757
12785
  function isType(suffix) {
12758
12786
  return function(url) {
12759
12787
  return url == null ? void 0 : url.split("?")[0].toLowerCase().includes(suffix);
@@ -12786,17 +12814,35 @@ var __publicField = (obj, key, value) => {
12786
12814
  if (codec === Codec.H265) {
12787
12815
  return sniffer.isHevcSupported();
12788
12816
  }
12789
- return sniffer.isMSESupport();
12817
+ if (codec === Codec.H264) {
12818
+ return sniffer.isMSESupport();
12819
+ }
12820
+ return sniffer.isMSESupport(codec);
12790
12821
  }
12791
12822
  async function isSoftDecodeSupported() {
12792
12823
  const { XGVideoPlugin } = await load(DynamicModule.PluginXgvideo);
12793
12824
  return XGVideoPlugin == null ? void 0 : XGVideoPlugin.isSupported();
12794
12825
  }
12826
+ function isMMSSupported(codec = Codec.H264) {
12827
+ if (typeof window.ManagedMediaSource === "undefined") {
12828
+ return false;
12829
+ }
12830
+ if (codec === Codec.H264) {
12831
+ return window.ManagedMediaSource.isTypeSupported(H264_MIME);
12832
+ }
12833
+ if (codec === Codec.H265) {
12834
+ return H265_MIME.some((mine) => {
12835
+ return window.ManagedMediaSource.isTypeSupported(mine);
12836
+ });
12837
+ }
12838
+ return window.ManagedMediaSource.isTypeSupported(codec);
12839
+ }
12795
12840
  ({
12796
12841
  ...util,
12797
12842
  getStreamType,
12798
12843
  isMseSupported,
12799
12844
  isSoftDecodeSupported,
12845
+ isMMSSupported,
12800
12846
  appendSearchParams,
12801
12847
  getUrlObject
12802
12848
  });
@@ -13009,7 +13055,6 @@ var __publicField = (obj, key, value) => {
13009
13055
  }
13010
13056
  // 有音量修改,取消静音
13011
13057
  handleVolumechange() {
13012
- this._state.mode = this.player.muted ? 1 : 0;
13013
13058
  if (!this._state.showUnmuteBt)
13014
13059
  return;
13015
13060
  this._state.showUnmuteBt = false;
@@ -13415,28 +13460,33 @@ var __publicField = (obj, key, value) => {
13415
13460
  useCssFullscreen: false
13416
13461
  }
13417
13462
  };
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
13463
+ const transformOption = (
13464
+ /** {zh}
13465
+ * @param options 更多配置信息。
13466
+ */
13467
+ (options) => {
13468
+ const { autoplay: autoplay2, ...rest } = options;
13469
+ const xgOptions = rest;
13470
+ if (xgOptions.poster) {
13471
+ xgOptions.poster = escapeHtml(xgOptions.poster);
13472
+ }
13473
+ xgOptions.icons = {
13474
+ ...DEFAULT_ICONS,
13475
+ ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13434
13476
  };
13435
- xgOptions.autoplayPlugin = autoplay2;
13477
+ xgOptions.autoplay = Boolean(autoplay2);
13478
+ if (autoplay2 && typeof autoplay2 !== "boolean") {
13479
+ xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13480
+ xgOptions.videoAttributes = {
13481
+ ...xgOptions.videoAttributes ?? {},
13482
+ muted: autoplay2 == null ? void 0 : autoplay2.muted
13483
+ };
13484
+ xgOptions.autoplayPlugin = autoplay2;
13485
+ }
13486
+ delete xgOptions.i18n;
13487
+ return xgOptions;
13436
13488
  }
13437
- delete xgOptions.i18n;
13438
- return xgOptions;
13439
- };
13489
+ );
13440
13490
  class VePlayerBase {
13441
13491
  /** {zh}
13442
13492
  * @hidden
@@ -13456,7 +13506,9 @@ var __publicField = (obj, key, value) => {
13456
13506
  this._sourceManager = options.sourceManager;
13457
13507
  this._preparePlugins = options.preparePlugins;
13458
13508
  this._previousPrepareResult = options.prepareResult;
13459
- this._i18nManager = options.i18nManager ?? new VeI18n({ i18n: options.i18n });
13509
+ this._i18nManager = options.i18nManager ?? new VeI18n({
13510
+ i18n: options.i18n
13511
+ });
13460
13512
  const xgOptions = transformOption({
13461
13513
  ...options,
13462
13514
  ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
@@ -13651,9 +13703,14 @@ var __publicField = (obj, key, value) => {
13651
13703
  /** {zh}
13652
13704
  * 获取播放器版本号
13653
13705
  * @returns
13706
+ * @brief
13707
+ * 获取播放器 SDK 版本号。
13708
+ */
13709
+ /** {en}
13710
+ * @brief Retrieve the player SDK version number.
13654
13711
  */
13655
13712
  get playerVersion() {
13656
- return "2.5.0-rc.1";
13713
+ return "2.5.1-rc.0";
13657
13714
  }
13658
13715
  /** {zh}
13659
13716
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -13801,8 +13858,8 @@ var __publicField = (obj, key, value) => {
13801
13858
  }
13802
13859
  /** {zh}
13803
13860
  * @brief 调用此方法切换拉流地址、线路、清晰度。
13804
- * @param target 目标地址,可以是播放地址,也可以是线路和清晰度
13805
- * @param options 更多配置信息
13861
+ * @param target 目标地址,可以是播放地址,也可以是线路和清晰度。
13862
+ * @param options 更多配置信息。
13806
13863
  */
13807
13864
  /** {en}
13808
13865
  * @brief Switches the pull stream address, playback source, or resolution.
@@ -13813,7 +13870,9 @@ var __publicField = (obj, key, value) => {
13813
13870
  var _a, _b;
13814
13871
  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
13872
  this._sourceManager.updateSources(target);
13816
- await this._switchUrl(target, { seamless: options == null ? void 0 : options.seamless });
13873
+ await this._switchUrl(target, {
13874
+ seamless: options == null ? void 0 : options.seamless
13875
+ });
13817
13876
  return this._sourceManager.definition;
13818
13877
  }
13819
13878
  const targetDefinition = this._sourceManager.find(target, options);
@@ -13840,16 +13899,15 @@ var __publicField = (obj, key, value) => {
13840
13899
  return this._switch(sourceManager.definition);
13841
13900
  }
13842
13901
  // TODO: 等西瓜播放器完善错误码后增加函数重载以提供更好的类型
13843
- /**
13844
13902
  /** {zh}
13845
13903
  * @brief 调用此方法监听指定事件,事件处理函数只执行一次。
13846
13904
  * @param event 表示事件的名称。
13847
13905
  * @param callback 表示事件的回调函数。
13848
13906
  */
13849
13907
  /** {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.
13908
+ * @brief Call this method to listen for the specified event. The event handler is executed only once.
13909
+ * @param event The name representing the event.
13910
+ * @param callback Callback functions representing events.
13853
13911
  */
13854
13912
  once(event, callback) {
13855
13913
  var _a;
@@ -14000,10 +14058,14 @@ var __publicField = (obj, key, value) => {
14000
14058
  return this._player.blur(data);
14001
14059
  }
14002
14060
  /** {zh}
14003
- * @brief 判断浏览器是否支持播放格式
14004
- * @param type 播放格式
14061
+ * @brief 判断浏览器是否支持播放格式。
14062
+ * @param type 播放格式。
14005
14063
  * @returns
14006
14064
  */
14065
+ /** {en}
14066
+ * @brief Determine whether the browser supports the playback format.
14067
+ * @param type The playback format.
14068
+ */
14007
14069
  canPlayType(type) {
14008
14070
  return this._player.canPlayType(type);
14009
14071
  }
@@ -14075,7 +14137,7 @@ var __publicField = (obj, key, value) => {
14075
14137
  }
14076
14138
  /** {zh}
14077
14139
  * @brief 调用此接口显示指定插件图标。
14078
- * @param pluginNames 插件名称
14140
+ * @param pluginNames 插件名称。
14079
14141
  */
14080
14142
  /** {en}
14081
14143
  * @brief Displays the icon of a specified plugin.
@@ -14096,7 +14158,7 @@ var __publicField = (obj, key, value) => {
14096
14158
  }
14097
14159
  /** {zh}
14098
14160
  * @brief 调用此接口隐藏指定插件图标。
14099
- * @param pluginNames 插件名称
14161
+ * @param pluginNames 插件名称。
14100
14162
  */
14101
14163
  /** {en}
14102
14164
  * @brief Hides the icon of a specified plugin.
@@ -14168,7 +14230,14 @@ var __publicField = (obj, key, value) => {
14168
14230
  this._player.once("canplay", () => {
14169
14231
  this._sourceManager.resetFallback();
14170
14232
  });
14171
- this.emit(Events.FALLBACK, { from: { url: preUrl }, to: { url } });
14233
+ this.emit(Events.FALLBACK, {
14234
+ from: {
14235
+ url: preUrl
14236
+ },
14237
+ to: {
14238
+ url
14239
+ }
14240
+ });
14172
14241
  this._switchUrl(url);
14173
14242
  }
14174
14243
  // eslint-disable-next-line @typescript-eslint/no-explicit-any