@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.
@@ -1461,7 +1461,7 @@ var __publicField = (obj, key, value) => {
1461
1461
  }
1462
1462
  }
1463
1463
  };
1464
- var version = "3.0.20-alpha.4";
1464
+ var version = "3.0.21-rc.5";
1465
1465
  var ERROR_TYPE_MAP = {
1466
1466
  1: "media",
1467
1467
  2: "media",
@@ -1917,7 +1917,7 @@ var __publicField = (obj, key, value) => {
1917
1917
  var _e = this.media.error || error2;
1918
1918
  var type = _e.code ? ERROR_TYPE_MAP[_e.code] : "other";
1919
1919
  var message = _e.message;
1920
- if (!this.media.currentSrc) {
1920
+ if (!(this.media.currentSrc || this.media.srcObject)) {
1921
1921
  message = "empty_src";
1922
1922
  _e = {
1923
1923
  code: 6,
@@ -2812,6 +2812,18 @@ var __publicField = (obj, key, value) => {
2812
2812
  }
2813
2813
  }
2814
2814
  }
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
+ }
2815
2827
  }, {
2816
2828
  key: "defaultConfig",
2817
2829
  get: function get() {
@@ -3457,7 +3469,7 @@ var __publicField = (obj, key, value) => {
3457
3469
  if (!this.observer) {
3458
3470
  return;
3459
3471
  }
3460
- this.observer && this.observer.observe(target);
3472
+ this.observer.observe(target);
3461
3473
  var _pid = target.getAttribute(PLATER_ID);
3462
3474
  var __handlers = this.__handlers;
3463
3475
  var index = -1;
@@ -3486,16 +3498,17 @@ var __publicField = (obj, key, value) => {
3486
3498
  }
3487
3499
  });
3488
3500
  try {
3489
- this.observer && this.observer.unobserve(target);
3501
+ var _this$observer;
3502
+ (_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.unobserve(target);
3490
3503
  } catch (e2) {
3491
3504
  }
3492
- this.observer && this.observer.unobserve(target);
3493
3505
  i2 > -1 && this.__handlers.splice(i2, 1);
3494
3506
  }
3495
3507
  }, {
3496
3508
  key: "destroyObserver",
3497
3509
  value: function destroyObserver() {
3498
- this.observer && this.observer.disconnect();
3510
+ var _this$observer2;
3511
+ (_this$observer2 = this.observer) === null || _this$observer2 === void 0 ? void 0 : _this$observer2.disconnect();
3499
3512
  this.observer = null;
3500
3513
  this.__handlers = null;
3501
3514
  }
@@ -3527,7 +3540,8 @@ var __publicField = (obj, key, value) => {
3527
3540
  return resizeObserver;
3528
3541
  }
3529
3542
  function unObserver(target, handler) {
3530
- resizeObserver.unObserver(target, handler);
3543
+ var _resizeObserver;
3544
+ (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.unObserver(target, handler);
3531
3545
  }
3532
3546
  var pluginsManager = {
3533
3547
  pluginGroup: {},
@@ -4117,6 +4131,10 @@ var __publicField = (obj, key, value) => {
4117
4131
  this.unbind("mouseenter", this.onMouseEnter);
4118
4132
  this.unbind("mouseleave", this.onMouseLeave);
4119
4133
  }
4134
+ this.left = null;
4135
+ this.center = null;
4136
+ this.right = null;
4137
+ this.innerRoot = null;
4120
4138
  }
4121
4139
  }, {
4122
4140
  key: "render",
@@ -5119,7 +5137,7 @@ var __publicField = (obj, key, value) => {
5119
5137
  if (!url) {
5120
5138
  url = _this8.url || _this8.config.url;
5121
5139
  }
5122
- var _furl = _this8._preProcessUrl(url);
5140
+ var _furl = _this8.preProcessUrl(url);
5123
5141
  var ret = _this8._startInit(_furl.url);
5124
5142
  return ret;
5125
5143
  }).catch(function(e2) {
@@ -5137,7 +5155,7 @@ var __publicField = (obj, key, value) => {
5137
5155
  if (util$1.typeOf(url) === "Object") {
5138
5156
  _src = url.url;
5139
5157
  }
5140
- _src = this._preProcessUrl(_src).url;
5158
+ _src = this.preProcessUrl(_src).url;
5141
5159
  var curTime = this.currentTime;
5142
5160
  this.__startTime = curTime;
5143
5161
  var isPaused = this.paused && !this.isError;
@@ -5478,7 +5496,7 @@ var __publicField = (obj, key, value) => {
5478
5496
  runHooks(this, "retry", function() {
5479
5497
  var cur = _this20.currentTime;
5480
5498
  var url = _this20.config.url;
5481
- var _srcRet = !util$1.isMSE(_this20.media) ? _this20._preProcessUrl(url) : {
5499
+ var _srcRet = !util$1.isMSE(_this20.media) ? _this20.preProcessUrl(url) : {
5482
5500
  url
5483
5501
  };
5484
5502
  _this20.src = _srcRet.url;
@@ -6134,11 +6152,11 @@ var __publicField = (obj, key, value) => {
6134
6152
  this._state = newState;
6135
6153
  }
6136
6154
  }, {
6137
- key: "_preProcessUrl",
6138
- value: function _preProcessUrl(url, ext) {
6139
- var _this$config7 = this.config, preProcessUrl = _this$config7.preProcessUrl, preProcessUrlOptions = _this$config7.preProcessUrlOptions;
6155
+ key: "preProcessUrl",
6156
+ value: function preProcessUrl(url, ext) {
6157
+ var _this$config7 = this.config, preProcessUrl2 = _this$config7.preProcessUrl, preProcessUrlOptions = _this$config7.preProcessUrlOptions;
6140
6158
  var processUrlOptions = Object.assign({}, preProcessUrlOptions, ext);
6141
- return !util$1.isBlob(url) && typeof preProcessUrl === "function" ? preProcessUrl(url, processUrlOptions) : {
6159
+ return !util$1.isBlob(url) && typeof preProcessUrl2 === "function" ? preProcessUrl2(url, processUrlOptions) : {
6142
6160
  url
6143
6161
  };
6144
6162
  }
@@ -6720,11 +6738,11 @@ var __publicField = (obj, key, value) => {
6720
6738
  } : error2;
6721
6739
  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"));
6722
6740
  super(message);
6723
- /**
6741
+ /** {zh}
6724
6742
  * @brief 错误码。
6725
6743
  */
6726
6744
  /** {en}
6727
- * @brief The error code.
6745
+ * @brief Error code.
6728
6746
  */
6729
6747
  __publicField(this, "errorCode");
6730
6748
  /** {zh}
@@ -8510,7 +8528,7 @@ var __publicField = (obj, key, value) => {
8510
8528
  }
8511
8529
  this.on(DURATION_CHANGE, function() {
8512
8530
  var player2 = _this2.player, config2 = _this2.config;
8513
- if (player2.duration * 1e3 < config2.moveDuration) {
8531
+ if (player2.duration > 0 && player2.duration * 1e3 < config2.moveDuration) {
8514
8532
  config2.moveDuration = player2.duration * 1e3;
8515
8533
  }
8516
8534
  });
@@ -8824,10 +8842,13 @@ var __publicField = (obj, key, value) => {
8824
8842
  }, {
8825
8843
  key: "updateBrightness",
8826
8844
  value: function updateBrightness(percent) {
8845
+ var pos = this.pos, config = this.config, xgMask = this.xgMask;
8846
+ if (!config.darkness) {
8847
+ return;
8848
+ }
8827
8849
  if (this.player.rotateDeg) {
8828
8850
  percent = -percent;
8829
8851
  }
8830
- var pos = this.pos, config = this.config, xgMask = this.xgMask;
8831
8852
  var light = pos.light + 0.8 * percent;
8832
8853
  light = light > config.maxDarkness ? config.maxDarkness : light < 0 ? 0 : light;
8833
8854
  if (xgMask) {
@@ -8888,12 +8909,12 @@ var __publicField = (obj, key, value) => {
8888
8909
  }, {
8889
8910
  key: "disableGesture",
8890
8911
  value: function disableGesture() {
8891
- this.config.disableGesture = false;
8912
+ this.config.disableGesture = true;
8892
8913
  }
8893
8914
  }, {
8894
8915
  key: "enableGesture",
8895
8916
  value: function enableGesture() {
8896
- this.config.disableGesture = true;
8917
+ this.config.disableGesture = false;
8897
8918
  }
8898
8919
  }, {
8899
8920
  key: "destroy",
@@ -9762,7 +9783,7 @@ var __publicField = (obj, key, value) => {
9762
9783
  }, {
9763
9784
  key: "toggleFullScreen",
9764
9785
  value: function toggleFullScreen(e2) {
9765
- if (e2) {
9786
+ if (e2 instanceof Event) {
9766
9787
  e2.preventDefault();
9767
9788
  e2.stopPropagation();
9768
9789
  }
@@ -10445,7 +10466,7 @@ var __publicField = (obj, key, value) => {
10445
10466
  key: "isPIPAvailable",
10446
10467
  value: function isPIPAvailable() {
10447
10468
  var video = this.player.media;
10448
- var _isEnabled = util$1.typeOf(document.pictureInPictureEnabled) === "Boolean" ? document.pictureInPictureEnabled : true;
10469
+ var _isEnabled = util$1.typeOf(document.pictureInPictureEnabled) === "Boolean" ? document.pictureInPictureEnabled : false;
10449
10470
  return _isEnabled && (util$1.typeOf(video.disablePictureInPicture) === "Boolean" && !video.disablePictureInPicture || video.webkitSupportsPresentationMode && util$1.typeOf(video.webkitSetPresentationMode) === "Function") || this.isDocPIPAvailable();
10450
10471
  }
10451
10472
  }, {
@@ -12827,7 +12848,7 @@ var __publicField = (obj, key, value) => {
12827
12848
  });
12828
12849
  }
12829
12850
  }
12830
- const appendSearchParams = (url, searchParams) => {
12851
+ const appendSearchParams$1 = (url, searchParams) => {
12831
12852
  var _a, _b;
12832
12853
  const urlObject = getUrlObject(url);
12833
12854
  if (!url || !urlObject) {
@@ -12862,6 +12883,13 @@ var __publicField = (obj, key, value) => {
12862
12883
  return;
12863
12884
  }
12864
12885
  };
12886
+ const H264_MIME = 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
12887
+ const H265_MIME = [
12888
+ 'video/mp4;codecs="hev1.1.6.L120.90"',
12889
+ 'video/mp4;codecs="hev1.2.4.L120.90"',
12890
+ 'video/mp4;codecs="hev1.3.E.L120.90"',
12891
+ 'video/mp4;codecs="hev1.4.10.L120.90"'
12892
+ ];
12865
12893
  function isType(suffix) {
12866
12894
  return function(url) {
12867
12895
  return url == null ? void 0 : url.split("?")[0].toLowerCase().includes(suffix);
@@ -12890,22 +12918,40 @@ var __publicField = (obj, key, value) => {
12890
12918
  }
12891
12919
  return "unknown";
12892
12920
  }
12893
- function isMseSupported(codec = Codec.H264) {
12921
+ function isMseSupported$1(codec = Codec.H264) {
12894
12922
  if (codec === Codec.H265) {
12895
12923
  return sniffer$1.isHevcSupported();
12896
12924
  }
12897
- return sniffer$1.isMSESupport();
12925
+ if (codec === Codec.H264) {
12926
+ return sniffer$1.isMSESupport();
12927
+ }
12928
+ return sniffer$1.isMSESupport(codec);
12898
12929
  }
12899
12930
  async function isSoftDecodeSupported() {
12900
12931
  const { XGVideoPlugin } = await load(DynamicModule.PluginXgvideo);
12901
12932
  return XGVideoPlugin == null ? void 0 : XGVideoPlugin.isSupported();
12902
12933
  }
12934
+ function isMMSSupported$1(codec = Codec.H264) {
12935
+ if (typeof window.ManagedMediaSource === "undefined") {
12936
+ return false;
12937
+ }
12938
+ if (codec === Codec.H264) {
12939
+ return window.ManagedMediaSource.isTypeSupported(H264_MIME);
12940
+ }
12941
+ if (codec === Codec.H265) {
12942
+ return H265_MIME.some((mine) => {
12943
+ return window.ManagedMediaSource.isTypeSupported(mine);
12944
+ });
12945
+ }
12946
+ return window.ManagedMediaSource.isTypeSupported(codec);
12947
+ }
12903
12948
  const util = {
12904
12949
  ...util$1,
12905
12950
  getStreamType,
12906
- isMseSupported,
12951
+ isMseSupported: isMseSupported$1,
12907
12952
  isSoftDecodeSupported,
12908
- appendSearchParams,
12953
+ isMMSSupported: isMMSSupported$1,
12954
+ appendSearchParams: appendSearchParams$1,
12909
12955
  getUrlObject
12910
12956
  };
12911
12957
  var autoplay = "";
@@ -13117,7 +13163,6 @@ var __publicField = (obj, key, value) => {
13117
13163
  }
13118
13164
  // 有音量修改,取消静音
13119
13165
  handleVolumechange() {
13120
- this._state.mode = this.player.muted ? 1 : 0;
13121
13166
  if (!this._state.showUnmuteBt)
13122
13167
  return;
13123
13168
  this._state.showUnmuteBt = false;
@@ -13577,28 +13622,33 @@ var __publicField = (obj, key, value) => {
13577
13622
  useCssFullscreen: false
13578
13623
  }
13579
13624
  };
13580
- const transformOption = (options) => {
13581
- const { autoplay: autoplay2, ...rest } = options;
13582
- const xgOptions = rest;
13583
- if (xgOptions.poster) {
13584
- xgOptions.poster = escapeHtml(xgOptions.poster);
13585
- }
13586
- xgOptions.icons = {
13587
- ...DEFAULT_ICONS,
13588
- ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13589
- };
13590
- xgOptions.autoplay = Boolean(autoplay2);
13591
- if (autoplay2 && typeof autoplay2 !== "boolean") {
13592
- xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13593
- xgOptions.videoAttributes = {
13594
- ...xgOptions.videoAttributes ?? {},
13595
- muted: autoplay2 == null ? void 0 : autoplay2.muted
13625
+ const transformOption = (
13626
+ /** {zh}
13627
+ * @param options 更多配置信息。
13628
+ */
13629
+ (options) => {
13630
+ const { autoplay: autoplay2, ...rest } = options;
13631
+ const xgOptions = rest;
13632
+ if (xgOptions.poster) {
13633
+ xgOptions.poster = escapeHtml(xgOptions.poster);
13634
+ }
13635
+ xgOptions.icons = {
13636
+ ...DEFAULT_ICONS,
13637
+ ...xgOptions.icons ? escapeIcons(xgOptions.icons) : {}
13596
13638
  };
13597
- xgOptions.autoplayPlugin = autoplay2;
13639
+ xgOptions.autoplay = Boolean(autoplay2);
13640
+ if (autoplay2 && typeof autoplay2 !== "boolean") {
13641
+ xgOptions.autoplayMuted = autoplay2 == null ? void 0 : autoplay2.muted;
13642
+ xgOptions.videoAttributes = {
13643
+ ...xgOptions.videoAttributes ?? {},
13644
+ muted: autoplay2 == null ? void 0 : autoplay2.muted
13645
+ };
13646
+ xgOptions.autoplayPlugin = autoplay2;
13647
+ }
13648
+ delete xgOptions.i18n;
13649
+ return xgOptions;
13598
13650
  }
13599
- delete xgOptions.i18n;
13600
- return xgOptions;
13601
- };
13651
+ );
13602
13652
  class VePlayerBase {
13603
13653
  /** {zh}
13604
13654
  * @hidden
@@ -13618,7 +13668,9 @@ var __publicField = (obj, key, value) => {
13618
13668
  this._sourceManager = options.sourceManager;
13619
13669
  this._preparePlugins = options.preparePlugins;
13620
13670
  this._previousPrepareResult = options.prepareResult;
13621
- this._i18nManager = options.i18nManager ?? new VeI18n({ i18n: options.i18n });
13671
+ this._i18nManager = options.i18nManager ?? new VeI18n({
13672
+ i18n: options.i18n
13673
+ });
13622
13674
  const xgOptions = transformOption({
13623
13675
  ...options,
13624
13676
  ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
@@ -13813,9 +13865,14 @@ var __publicField = (obj, key, value) => {
13813
13865
  /** {zh}
13814
13866
  * 获取播放器版本号
13815
13867
  * @returns
13868
+ * @brief
13869
+ * 获取播放器 SDK 版本号。
13870
+ */
13871
+ /** {en}
13872
+ * @brief Retrieve the player SDK version number.
13816
13873
  */
13817
13874
  get playerVersion() {
13818
- return "2.5.0-rc.1";
13875
+ return "2.5.1-rc.0";
13819
13876
  }
13820
13877
  /** {zh}
13821
13878
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -13963,8 +14020,8 @@ var __publicField = (obj, key, value) => {
13963
14020
  }
13964
14021
  /** {zh}
13965
14022
  * @brief 调用此方法切换拉流地址、线路、清晰度。
13966
- * @param target 目标地址,可以是播放地址,也可以是线路和清晰度
13967
- * @param options 更多配置信息
14023
+ * @param target 目标地址,可以是播放地址,也可以是线路和清晰度。
14024
+ * @param options 更多配置信息。
13968
14025
  */
13969
14026
  /** {en}
13970
14027
  * @brief Switches the pull stream address, playback source, or resolution.
@@ -13975,7 +14032,9 @@ var __publicField = (obj, key, value) => {
13975
14032
  var _a, _b;
13976
14033
  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) {
13977
14034
  this._sourceManager.updateSources(target);
13978
- await this._switchUrl(target, { seamless: options == null ? void 0 : options.seamless });
14035
+ await this._switchUrl(target, {
14036
+ seamless: options == null ? void 0 : options.seamless
14037
+ });
13979
14038
  return this._sourceManager.definition;
13980
14039
  }
13981
14040
  const targetDefinition = this._sourceManager.find(target, options);
@@ -14002,16 +14061,15 @@ var __publicField = (obj, key, value) => {
14002
14061
  return this._switch(sourceManager.definition);
14003
14062
  }
14004
14063
  // TODO: 等西瓜播放器完善错误码后增加函数重载以提供更好的类型
14005
- /**
14006
14064
  /** {zh}
14007
14065
  * @brief 调用此方法监听指定事件,事件处理函数只执行一次。
14008
14066
  * @param event 表示事件的名称。
14009
14067
  * @param callback 表示事件的回调函数。
14010
14068
  */
14011
14069
  /** {en}
14012
- * @brief Add a one-time listener function for the specified event.
14013
- * @param event The event name.
14014
- * @param callback The callback function for the event.
14070
+ * @brief Call this method to listen for the specified event. The event handler is executed only once.
14071
+ * @param event The name representing the event.
14072
+ * @param callback Callback functions representing events.
14015
14073
  */
14016
14074
  once(event, callback) {
14017
14075
  var _a;
@@ -14162,10 +14220,14 @@ var __publicField = (obj, key, value) => {
14162
14220
  return this._player.blur(data);
14163
14221
  }
14164
14222
  /** {zh}
14165
- * @brief 判断浏览器是否支持播放格式
14166
- * @param type 播放格式
14223
+ * @brief 判断浏览器是否支持播放格式。
14224
+ * @param type 播放格式。
14167
14225
  * @returns
14168
14226
  */
14227
+ /** {en}
14228
+ * @brief Determine whether the browser supports the playback format.
14229
+ * @param type The playback format.
14230
+ */
14169
14231
  canPlayType(type) {
14170
14232
  return this._player.canPlayType(type);
14171
14233
  }
@@ -14237,7 +14299,7 @@ var __publicField = (obj, key, value) => {
14237
14299
  }
14238
14300
  /** {zh}
14239
14301
  * @brief 调用此接口显示指定插件图标。
14240
- * @param pluginNames 插件名称
14302
+ * @param pluginNames 插件名称。
14241
14303
  */
14242
14304
  /** {en}
14243
14305
  * @brief Displays the icon of a specified plugin.
@@ -14258,7 +14320,7 @@ var __publicField = (obj, key, value) => {
14258
14320
  }
14259
14321
  /** {zh}
14260
14322
  * @brief 调用此接口隐藏指定插件图标。
14261
- * @param pluginNames 插件名称
14323
+ * @param pluginNames 插件名称。
14262
14324
  */
14263
14325
  /** {en}
14264
14326
  * @brief Hides the icon of a specified plugin.
@@ -14330,7 +14392,14 @@ var __publicField = (obj, key, value) => {
14330
14392
  this._player.once("canplay", () => {
14331
14393
  this._sourceManager.resetFallback();
14332
14394
  });
14333
- this.emit(Events$1.FALLBACK, { from: { url: preUrl }, to: { url } });
14395
+ this.emit(Events$1.FALLBACK, {
14396
+ from: {
14397
+ url: preUrl
14398
+ },
14399
+ to: {
14400
+ url
14401
+ }
14402
+ });
14334
14403
  this._switchUrl(url);
14335
14404
  }
14336
14405
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -18924,46 +18993,6 @@ var __publicField = (obj, key, value) => {
18924
18993
  return result;
18925
18994
  }
18926
18995
  }
18927
- const getFlvStrategy = async (options) => {
18928
- var _a, _b, _c, _d, _e, _f;
18929
- let mseStrategy;
18930
- let softStrategy;
18931
- const enableLowLatency = ((_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency) && sniffer$1.device === "pc";
18932
- const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
18933
- const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
18934
- const codec = await getCodec(options);
18935
- const isSoftDecode$1 = await isSoftDecode(options, codec);
18936
- if (isSoftDecode$1) {
18937
- softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
18938
- mseStrategy = createFlvMseStrategy(options);
18939
- }
18940
- if (codec === "unknown" ? isMseSupported(Codec.H264) : isMseSupported(codec)) {
18941
- mseStrategy = createFlvMseStrategy(options);
18942
- }
18943
- if (!mseStrategy && !softStrategy) {
18944
- return {};
18945
- }
18946
- const [mseModule, softModule] = await Promise.all([
18947
- (mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
18948
- (softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
18949
- ]);
18950
- (softModule == null ? void 0 : softModule.XGVideoPlugin) && ((_f = softStrategy == null ? void 0 : softStrategy.afterLoad) == null ? void 0 : _f.call(softStrategy, softModule == null ? void 0 : softModule.XGVideoPlugin));
18951
- const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
18952
- const plugins = [];
18953
- if (enableLowLatency) {
18954
- combineOptions$1.url = appendSearchParams(options.url, { abr_pts: abrPts });
18955
- }
18956
- if (mseModule) {
18957
- plugins.push(mseModule.FlvPlugin);
18958
- if (enableLowLatency && enableFrameChasing) {
18959
- plugins.push(mseModule.Adaptive);
18960
- }
18961
- }
18962
- return {
18963
- options: combineOptions$1,
18964
- plugins
18965
- };
18966
- };
18967
18996
  const getHlsStrategy = async (options) => {
18968
18997
  var _a, _b;
18969
18998
  let mseStrategy;
@@ -18974,7 +19003,7 @@ var __publicField = (obj, key, value) => {
18974
19003
  softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
18975
19004
  mseStrategy = createHlsMseStrategy(options);
18976
19005
  }
18977
- if ((sniffer$1.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && (codec === "unknown" ? isMseSupported(Codec.H264) : isMseSupported(codec))) {
19006
+ if ((sniffer$1.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && (codec === "unknown" ? isMseSupported$1(Codec.H264) : isMseSupported$1(codec))) {
18978
19007
  mseStrategy = createHlsMseStrategy(options);
18979
19008
  }
18980
19009
  if (!mseStrategy && !softStrategy) {
@@ -18991,24 +19020,38 @@ var __publicField = (obj, key, value) => {
18991
19020
  plugins: (mseModule == null ? void 0 : mseModule.HlsPlugin) ? [mseModule.HlsPlugin] : []
18992
19021
  };
18993
19022
  };
18994
- const createFlvMseStrategy = (options) => {
19023
+ const getDefaultFlvOptions = (options) => {
18995
19024
  var _a;
18996
19025
  return {
18997
- options: {
18998
- flv: {
18999
- retryCount: 0,
19000
- disconnectRetryCount: ((_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.retryCount) ?? void 0,
19001
- ...(options == null ? void 0 : options.flv) ?? {}
19002
- }
19003
- },
19004
- module: DynamicModule.PluginFlv
19026
+ retryCount: 0,
19027
+ disconnectRetryCount: ((_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.retryCount) ?? void 0
19005
19028
  };
19006
19029
  };
19030
+ const createFlvMseStrategy = (options) => ({
19031
+ options: {
19032
+ flv: {
19033
+ ...getDefaultFlvOptions(options),
19034
+ ...(options == null ? void 0 : options.flv) ?? {}
19035
+ }
19036
+ },
19037
+ module: DynamicModule.PluginFlv
19038
+ });
19039
+ const createFlvMssStrategy = (options) => ({
19040
+ options: {
19041
+ flv: {
19042
+ preferMMS: true,
19043
+ ...getDefaultFlvOptions(options),
19044
+ ...(options == null ? void 0 : options.flv) ?? {}
19045
+ }
19046
+ },
19047
+ module: DynamicModule.PluginFlv
19048
+ });
19007
19049
  const createHlsMseStrategy = (options) => ({
19008
19050
  options: {
19009
19051
  hls: {
19010
19052
  retryCount: 0,
19011
19053
  pollRetryCount: 0,
19054
+ allowedStreamTrackChange: false,
19012
19055
  ...(options == null ? void 0 : options.hls) ?? {}
19013
19056
  }
19014
19057
  },
@@ -19107,6 +19150,7 @@ var __publicField = (obj, key, value) => {
19107
19150
  const { VeError } = error$1;
19108
19151
  var LiveErrorCode = /* @__PURE__ */ ((LiveErrorCode2) => {
19109
19152
  LiveErrorCode2[LiveErrorCode2["INVALID_PARAMETER"] = 210] = "INVALID_PARAMETER";
19153
+ LiveErrorCode2[LiveErrorCode2["INVALID_LOGGER"] = 220] = "INVALID_LOGGER";
19110
19154
  return LiveErrorCode2;
19111
19155
  })(LiveErrorCode || {});
19112
19156
  const ErrorCode = {
@@ -19121,10 +19165,23 @@ var __publicField = (obj, key, value) => {
19121
19165
  ]: {
19122
19166
  messageTextKey: "INVALID_PARAMETER",
19123
19167
  level: Level.Fatal
19168
+ },
19169
+ [
19170
+ 220
19171
+ /* INVALID_LOGGER */
19172
+ ]: {
19173
+ messageTextKey: "INVALID_LOGGER",
19174
+ level: Level.Error
19124
19175
  }
19125
19176
  };
19126
19177
  function create(errorCode, i18n) {
19127
- return new VeError(ERRORS[errorCode], i18n);
19178
+ return new VeError(
19179
+ {
19180
+ errorCode,
19181
+ ...ERRORS[errorCode]
19182
+ },
19183
+ i18n
19184
+ );
19128
19185
  }
19129
19186
  async function isRTMSupported() {
19130
19187
  const { RtmPlugin } = await load(DynamicModule.PluginRtm);
@@ -19242,6 +19299,55 @@ var __publicField = (obj, key, value) => {
19242
19299
  }
19243
19300
  return true;
19244
19301
  }
19302
+ const { isMMSSupported, isMseSupported } = util;
19303
+ function enableMMS() {
19304
+ return sniffer$1.os.isIos;
19305
+ }
19306
+ function isFLVSupported(codec = Codec.H264) {
19307
+ const isMediaSourceSupported = enableMMS() ? isMMSSupported : isMseSupported;
19308
+ return isMediaSourceSupported(codec);
19309
+ }
19310
+ const { appendSearchParams } = util;
19311
+ const getFlvStrategy = async (options) => {
19312
+ var _a, _b, _c, _d, _e, _f;
19313
+ let mseStrategy;
19314
+ let softStrategy;
19315
+ const enableLowLatency = ((_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency) && sniffer$1.device === "pc";
19316
+ const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
19317
+ const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
19318
+ const codec = await getCodec(options);
19319
+ const isSoftDecode$1 = await isSoftDecode(options, codec);
19320
+ if (isSoftDecode$1) {
19321
+ softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
19322
+ mseStrategy = createFlvMseStrategy(options);
19323
+ }
19324
+ if (codec === "unknown" ? isFLVSupported(Codec.H264) : isFLVSupported(codec)) {
19325
+ mseStrategy = enableMMS() ? createFlvMssStrategy(options) : createFlvMseStrategy(options);
19326
+ }
19327
+ if (!mseStrategy && !softStrategy) {
19328
+ return {};
19329
+ }
19330
+ const [mseModule, softModule] = await Promise.all([
19331
+ (mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
19332
+ (softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
19333
+ ]);
19334
+ (softModule == null ? void 0 : softModule.XGVideoPlugin) && ((_f = softStrategy == null ? void 0 : softStrategy.afterLoad) == null ? void 0 : _f.call(softStrategy, softModule == null ? void 0 : softModule.XGVideoPlugin));
19335
+ const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
19336
+ const plugins = [];
19337
+ if (enableLowLatency) {
19338
+ combineOptions$1.url = appendSearchParams(options.url, { abr_pts: abrPts });
19339
+ }
19340
+ if (mseModule) {
19341
+ plugins.push(mseModule.FlvPlugin);
19342
+ if (enableLowLatency && enableFrameChasing) {
19343
+ plugins.push(mseModule.Adaptive);
19344
+ }
19345
+ }
19346
+ return {
19347
+ options: combineOptions$1,
19348
+ plugins
19349
+ };
19350
+ };
19245
19351
  const getTypeStrategy = async (options, player) => {
19246
19352
  const type = options.url ? util.getStreamType(options.url) : "";
19247
19353
  if (!type || type === "unknown") {
@@ -22005,7 +22111,7 @@ var __publicField = (obj, key, value) => {
22005
22111
  }
22006
22112
  static get defaultConfig() {
22007
22113
  return {
22008
- appId: "",
22114
+ appId: 654925,
22009
22115
  enable: true,
22010
22116
  showUserIdInErrorPanel: true
22011
22117
  };
@@ -22015,10 +22121,6 @@ var __publicField = (obj, key, value) => {
22015
22121
  if (!this.config.enable) {
22016
22122
  return;
22017
22123
  }
22018
- if (!this.config.appId) {
22019
- console.info("not found appId, please generate an appId");
22020
- return;
22021
- }
22022
22124
  this._userId = ((_a = this.config) == null ? void 0 : _a.userId) || getUserId();
22023
22125
  this._deviceId = ((_b = this.config) == null ? void 0 : _b.deviceId) || getDeviceID();
22024
22126
  this.open();
@@ -22061,16 +22163,17 @@ var __publicField = (obj, key, value) => {
22061
22163
  this._liveLogger = new LoggerControl({
22062
22164
  Tea: q,
22063
22165
  player: this.player,
22064
- aid: this.config.appId,
22166
+ aid: this.config.appId || 654925,
22065
22167
  project_key: this.config.appId,
22066
22168
  app_name: this.config.appName || this.config.appId,
22067
22169
  user_id: this._userId,
22068
22170
  device_id: this._deviceId,
22171
+ error_report_stop: true,
22069
22172
  ext: {
22070
- veplayer_version: "2.5.0-rc.1",
22071
- flv_version: "3.0.19-rc.0",
22072
- hls_version: "3.0.20-alpha.2",
22073
- rts_version: "0.2.1-alpha.0"
22173
+ veplayer_version: "2.5.1-rc.0",
22174
+ flv_version: "3.0.21-rc.5",
22175
+ hls_version: "3.0.21-rc.5",
22176
+ rts_version: "0.2.1-alpha.14"
22074
22177
  }
22075
22178
  });
22076
22179
  }
@@ -22302,6 +22405,7 @@ var __publicField = (obj, key, value) => {
22302
22405
  const EN = {
22303
22406
  ...EN$1,
22304
22407
  INVALID_PARAMETER: "The imported parameter is empty, please pass in necessary parameters such as the stream address",
22408
+ INVALID_LOGGER: "Log options not configured correctly. Please refer to this document https://docs.byteplus.com/en/docs/byteplus-media-live/docs-feature-implementation#uploading-logs to configure the logs.",
22305
22409
  // info-panel
22306
22410
  FORMAT: "format",
22307
22411
  FPS: "fps",
@@ -22319,6 +22423,7 @@ var __publicField = (obj, key, value) => {
22319
22423
  const ZH_CN = {
22320
22424
  ...ZH_CN$1,
22321
22425
  INVALID_PARAMETER: "入参为空,请传入流地址等必要参数",
22426
+ INVALID_LOGGER: "未正确配置质量日志参数, 请参考 https://www.volcengine.com/docs/6469/138655#日志上报 配置",
22322
22427
  // info-panel
22323
22428
  FORMAT: "格式",
22324
22429
  FPS: "帧率",
@@ -22398,7 +22503,9 @@ var __publicField = (obj, key, value) => {
22398
22503
  }
22399
22504
  ]);
22400
22505
  const LIVE_DEFAULT_OPTIONS = {
22401
- autoplay: { muted: true }
22506
+ autoplay: {
22507
+ muted: true
22508
+ }
22402
22509
  };
22403
22510
  const LIVE_DEFAULT_PLUGINS = [...DEFAULT_PLUGINS, Refresh, Logger, InfoPanel];
22404
22511
  var RTMCodec = /* @__PURE__ */ ((RTMCodec2) => {
@@ -22418,7 +22525,10 @@ var __publicField = (obj, key, value) => {
22418
22525
  super(options);
22419
22526
  }
22420
22527
  /** {zh}
22421
- * @brief 获取已经播放的时间
22528
+ * @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
22529
+ */
22530
+ /** {en}
22531
+ * @brief Obtain the duration that has been played, excluding pause and waiting time, with the unit of seconds.
22422
22532
  */
22423
22533
  get playTime() {
22424
22534
  var _a, _b, _c, _d;
@@ -22477,7 +22587,10 @@ var __publicField = (obj, key, value) => {
22477
22587
  (_a = this._player.plugins) == null ? void 0 : _a.infopanel.close();
22478
22588
  }
22479
22589
  /** {zh}
22480
- * @brief 打开 Abr
22590
+ * @brief 打开码率自适应(ABR)切换功能。
22591
+ */
22592
+ /** {en}
22593
+ * @brief Enable the Adaptive Bitrate Streaming (ABR) switching feature.
22481
22594
  */
22482
22595
  openAbr() {
22483
22596
  var _a, _b, _c, _d;
@@ -22491,7 +22604,10 @@ var __publicField = (obj, key, value) => {
22491
22604
  }
22492
22605
  }
22493
22606
  /** {zh}
22494
- * @brief 关闭 Abr
22607
+ * @brief 关闭码率自适应(ABR)切换功能。
22608
+ */
22609
+ /** {en}
22610
+ * @brief Disable the Adaptive Bitrate Streaming (ABR) switching feature.
22495
22611
  */
22496
22612
  closeAbr() {
22497
22613
  var _a, _b, _c, _d;
@@ -22505,18 +22621,25 @@ var __publicField = (obj, key, value) => {
22505
22621
  }
22506
22622
  }
22507
22623
  /** {zh}
22508
- * @brief 调用此方法更新 DRM 鉴权配置。
22509
- * @hidden
22624
+ * @brief 调用此方法更新 DRM 配置。
22625
+ */
22626
+ /** {en}
22627
+ * @brief Use this method to update DRM configuration.
22628
+ * @param config
22510
22629
  */
22511
22630
  updateDrmConfig(config) {
22512
22631
  var _a, _b, _c;
22513
22632
  (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.drm) == null ? void 0 : _c.updateDrmConfig(config);
22514
22633
  }
22515
22634
  /** {zh}
22516
- * @brief 切换 flv Abr
22517
- * @param options 切换 Abr 的配置。
22635
+ * @brief 修改 ABR 配置,包含修改是否开启 ABR 功能,和修改其他清晰度。
22636
+ * @param options ABR 的配置。
22518
22637
  * @returns
22519
22638
  */
22639
+ /** {en}
22640
+ * @brief Modify ABR configuration, including enabling or disabling the ABR feature and adjusting other resolutions.
22641
+ * @param options Configuration of ABR.
22642
+ */
22520
22643
  switchAbr(options) {
22521
22644
  var _a, _b;
22522
22645
  if (!((_a = this._player.plugins) == null ? void 0 : _a.abr)) {
@@ -22527,7 +22650,9 @@ var __publicField = (obj, key, value) => {
22527
22650
  if (!url) {
22528
22651
  return;
22529
22652
  }
22530
- this.switch(url, { seamless: true });
22653
+ this.switch(url, {
22654
+ seamless: true
22655
+ });
22531
22656
  this._player.plugins.abr.bitrate = options.bitrate;
22532
22657
  }
22533
22658
  if (typeof (options == null ? void 0 : options.enable) !== "undefined") {
@@ -22535,37 +22660,52 @@ var __publicField = (obj, key, value) => {
22535
22660
  }
22536
22661
  }
22537
22662
  /** {zh}
22538
- * @brief 获取 RTM 的网络相关信息
22663
+ * @brief 获取 RTM 拉流的网络评估信息。
22539
22664
  * @returns
22540
22665
  */
22666
+ /** {en}
22667
+ * @brief Obtain the network assessment information of RTM pull streaming.
22668
+ */
22541
22669
  getRTMNetWorkInfo() {
22542
22670
  var _a, _b, _c;
22543
22671
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getNetWorkInfo();
22544
22672
  }
22545
22673
  /** {zh}
22546
- * @brief 获取 RTM 播放信息
22674
+ * @brief 获取 RTM 拉流的播放信息。
22547
22675
  * @returns
22548
22676
  */
22677
+ /** {en}
22678
+ * @brief Obtain the playback information of RTM pull stream.
22679
+ */
22549
22680
  async getRTMStats() {
22550
22681
  var _a, _b, _c;
22551
22682
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot();
22552
22683
  }
22553
22684
  /** {zh}
22554
- * @brief 获取 FLV 播放信息
22685
+ * @brief 获取 FLV 拉流的播放信息。
22555
22686
  * @returns
22556
22687
  */
22688
+ /** {en}
22689
+ * @brief Obtain the playback information of FLV pull streaming.
22690
+ */
22557
22691
  getFLVStats() {
22558
22692
  var _a, _b, _c;
22559
22693
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
22560
22694
  }
22561
22695
  }
22562
22696
  async function createLivePlayer(options) {
22563
- var _a, _b;
22697
+ var _a, _b, _c, _d;
22564
22698
  let player = void 0;
22699
+ const i18n = new VeI18n({
22700
+ lang: options == null ? void 0 : options.lang,
22701
+ i18n: options == null ? void 0 : options.i18n
22702
+ });
22565
22703
  if (!options || !options.url && !options.playlist) {
22566
- throw create(ErrorCode.INVALID_PARAMETER, new VeI18n());
22704
+ throw create(ErrorCode.INVALID_PARAMETER, i18n);
22705
+ }
22706
+ if (!((_a = options.logger) == null ? void 0 : _a.appId) && ((_b = options == null ? void 0 : options.logger) == null ? void 0 : _b.enable) !== false) {
22707
+ console.warn(create(ErrorCode.INVALID_LOGGER, i18n).message);
22567
22708
  }
22568
- const i18n = new VeI18n({ lang: options == null ? void 0 : options.lang, i18n: options == null ? void 0 : options.i18n });
22569
22709
  const finalOptions = {
22570
22710
  ...options,
22571
22711
  plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
@@ -22583,9 +22723,24 @@ var __publicField = (obj, key, value) => {
22583
22723
  },
22584
22724
  async preparePlugins(url) {
22585
22725
  const [typeStrategy, drmStrategy, abrStrategy] = await Promise.all([
22586
- getTypeStrategy({ ...finalOptions, url }, player),
22587
- getDrmStrategy({ ...finalOptions, url }, player),
22588
- getAbrStrategy({ ...finalOptions, url })
22726
+ getTypeStrategy(
22727
+ {
22728
+ ...finalOptions,
22729
+ url
22730
+ },
22731
+ player
22732
+ ),
22733
+ getDrmStrategy(
22734
+ {
22735
+ ...finalOptions,
22736
+ url
22737
+ },
22738
+ player
22739
+ ),
22740
+ getAbrStrategy({
22741
+ ...finalOptions,
22742
+ url
22743
+ })
22589
22744
  ]);
22590
22745
  const { options: options2, plugins } = typeStrategy ?? {};
22591
22746
  const { options: drmOptions, plugins: drmPlugins } = drmStrategy ?? {};
@@ -22603,7 +22758,7 @@ var __publicField = (obj, key, value) => {
22603
22758
  VePlayerLive
22604
22759
  );
22605
22760
  if (player) {
22606
- const RTMDegrade = (_b = (_a = player == null ? void 0 : player._player) == null ? void 0 : _a.config) == null ? void 0 : _b._RTMdegrade;
22761
+ const RTMDegrade = (_d = (_c = player == null ? void 0 : player._player) == null ? void 0 : _c.config) == null ? void 0 : _d._RTMdegrade;
22607
22762
  if (RTMDegrade) {
22608
22763
  player.emit("degrade", {
22609
22764
  originRtmUrl: RTMDegrade._originRtmUrl,
@@ -22624,6 +22779,7 @@ var __publicField = (obj, key, value) => {
22624
22779
  setModuleSystem("esm");
22625
22780
  util.isMseSupported;
22626
22781
  util.isSoftDecodeSupported;
22782
+ util.isMMSSupported;
22627
22783
  setModuleSystem("umd");
22628
22784
  exports2.Codec = Codec;
22629
22785
  exports2.DecodeType = DecodeType;
@@ -22637,7 +22793,9 @@ var __publicField = (obj, key, value) => {
22637
22793
  exports2.Sniffer = sniffer$1;
22638
22794
  exports2.ZH_CN = ZH_CN$1;
22639
22795
  exports2.createLivePlayer = createLivePlayer;
22640
- exports2.isMseSupported = isMseSupported;
22796
+ exports2.isFLVSupported = isFLVSupported;
22797
+ exports2.isMMSSupported = isMMSSupported$1;
22798
+ exports2.isMseSupported = isMseSupported$1;
22641
22799
  exports2.isRTMSupportCodec = isRTMSupportCodec;
22642
22800
  exports2.isRTMSupported = isRTMSupported;
22643
22801
  exports2.isSoftDecodeSupported = isSoftDecodeSupported;