@volcengine/veplayer 2.6.1 → 2.7.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.
@@ -11733,14 +11733,6 @@ class Sources extends OptionsIcon {
11733
11733
  const sourceManager = args.player.config.sources.sourceManager;
11734
11734
  args.config.list = sourceManager.sources;
11735
11735
  }
11736
- afterCreate() {
11737
- super.afterCreate();
11738
- if (this.config.sourceManager.sources.length < 2) {
11739
- this.hide();
11740
- } else {
11741
- this.renderItemList();
11742
- }
11743
- }
11744
11736
  registerIcons() {
11745
11737
  return {
11746
11738
  source: { icon: SourceIcon }
@@ -11749,6 +11741,10 @@ class Sources extends OptionsIcon {
11749
11741
  renderItemList() {
11750
11742
  const { sources, source } = this.config.sourceManager;
11751
11743
  const i18nManager = this.player.config.i18nManager;
11744
+ if (sources.length < 2) {
11745
+ this.hide();
11746
+ return;
11747
+ }
11752
11748
  const renderItems = sources.map((source2) => {
11753
11749
  return {
11754
11750
  ...source2,
@@ -12430,6 +12426,10 @@ class DefinitionPlugin extends OptionsIcon {
12430
12426
  var _a, _b;
12431
12427
  const sourceManager = this.player.config.sourceManager;
12432
12428
  const definitions = ((_a = sourceManager.source) == null ? void 0 : _a.definitions) ?? [];
12429
+ if (definitions.length < 2) {
12430
+ this.hide();
12431
+ return;
12432
+ }
12433
12433
  const renderItems = definitions.map((definition) => {
12434
12434
  const showItem = {
12435
12435
  url: definition.url,
@@ -14064,10 +14064,12 @@ class VePlayerBase {
14064
14064
  __publicField(this, "_events", {});
14065
14065
  __publicField(this, "_customMedia");
14066
14066
  __publicField(this, "_errorCallback");
14067
+ __publicField(this, "_beforeFallbackError");
14067
14068
  var _a, _b, _c, _d, _e, _f;
14068
14069
  this._sourceManager = options.sourceManager;
14069
14070
  this._preparePlugins = options.preparePlugins;
14070
14071
  this._previousPrepareResult = options.prepareResult;
14072
+ this._beforeFallbackError = options.beforeFallbackError;
14071
14073
  this._i18nManager = options.i18nManager ?? new VeI18n({
14072
14074
  i18n: options.i18n
14073
14075
  });
@@ -14092,6 +14094,9 @@ class VePlayerBase {
14092
14094
  ...DEFAULT_OPTIONS,
14093
14095
  ...xgOptions,
14094
14096
  definition: {
14097
+ // TODO: ts
14098
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14099
+ // @ts-ignore
14095
14100
  list: ((_d = this._sourceManager.source) == null ? void 0 : _d.definitions) ?? [],
14096
14101
  defaultDefinition: (_e = this._sourceManager.definition) == null ? void 0 : _e.definition,
14097
14102
  ...options.definition ?? {}
@@ -14150,7 +14155,7 @@ class VePlayerBase {
14150
14155
  return this._player.played;
14151
14156
  }
14152
14157
  /** {zh}
14153
- * @brief 设置/获取视频当前的播放时间, 单位为 s。
14158
+ * @brief 设置/获取视频当前的播放时间,单位为 s。
14154
14159
  */
14155
14160
  /** {en}
14156
14161
  * @brief Sets or gets the current playback position of the video, in seconds.
@@ -14276,7 +14281,7 @@ class VePlayerBase {
14276
14281
  * @brief Retrieve the player SDK version number.
14277
14282
  */
14278
14283
  get playerVersion() {
14279
- return "2.6.1";
14284
+ return "2.7.0-rc.0";
14280
14285
  }
14281
14286
  /** {zh}
14282
14287
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -14762,13 +14767,18 @@ class VePlayerBase {
14762
14767
  * @hidden
14763
14768
  */
14764
14769
  async prepare(url) {
14765
- var _a, _b, _c, _d, _e, _f, _g;
14770
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
14766
14771
  const result = await ((_a = this._preparePlugins) == null ? void 0 : _a.call(this, url));
14767
- const newUrl = ((_b = result == null ? void 0 : result.options) == null ? void 0 : _b.url) ?? url;
14768
- const oldUrl = (_d = (_c = this._player) == null ? void 0 : _c.config) == null ? void 0 : _d.url;
14769
- const isSameProtocol = oldUrl && getStreamType(newUrl) === getStreamType(oldUrl);
14772
+ let isSameProtocol;
14773
+ if ((result == null ? void 0 : result.protocol) && ((_b = this._previousPrepareResult) == null ? void 0 : _b.protocol)) {
14774
+ isSameProtocol = result.protocol === ((_c = this._previousPrepareResult) == null ? void 0 : _c.protocol);
14775
+ } else {
14776
+ const newUrl = ((_d = result == null ? void 0 : result.options) == null ? void 0 : _d.url) ?? url;
14777
+ const oldUrl = (_f = (_e = this._player) == null ? void 0 : _e.config) == null ? void 0 : _f.url;
14778
+ isSameProtocol = oldUrl && getStreamType(newUrl) === getStreamType(oldUrl);
14779
+ }
14770
14780
  if (!isSameProtocol) {
14771
- (_f = (_e = this._previousPrepareResult) == null ? void 0 : _e.plugins) == null ? void 0 : _f.forEach((plugin) => {
14781
+ (_h = (_g = this._previousPrepareResult) == null ? void 0 : _g.plugins) == null ? void 0 : _h.forEach((plugin) => {
14772
14782
  this._player.unRegisterPlugin(plugin.pluginName);
14773
14783
  });
14774
14784
  }
@@ -14777,7 +14787,7 @@ class VePlayerBase {
14777
14787
  this._player.setConfig(result.options);
14778
14788
  }
14779
14789
  return {
14780
- plugins: isSameProtocol ? [] : (_g = result == null ? void 0 : result.plugins) == null ? void 0 : _g.map((plugin) => {
14790
+ plugins: isSameProtocol ? [] : (_i = result == null ? void 0 : result.plugins) == null ? void 0 : _i.map((plugin) => {
14781
14791
  return this._player.registerPlugin(plugin);
14782
14792
  }),
14783
14793
  options: result == null ? void 0 : result.options,
@@ -14790,11 +14800,18 @@ class VePlayerBase {
14790
14800
  const preUrl = this._sourceManager.url;
14791
14801
  const url = this._sourceManager.fallback();
14792
14802
  if (!url) {
14803
+ const transformedError = transform$1(err, this._i18nManager);
14804
+ try {
14805
+ const { canEmitError } = await this._beforeFallbackError(
14806
+ transformedError
14807
+ );
14808
+ if (!canEmitError) {
14809
+ return;
14810
+ }
14811
+ } catch (error2) {
14812
+ }
14793
14813
  this._player.removeClass(STATE_CLASS.ENTER);
14794
- this.emit(
14795
- Events.FALLBACK_ERROR,
14796
- transform$1(err, this._i18nManager)
14797
- );
14814
+ this.emit(Events.FALLBACK_ERROR, transformedError);
14798
14815
  return;
14799
14816
  }
14800
14817
  this._player.once("canplay", () => {
@@ -14874,7 +14891,6 @@ class VePlayerBase {
14874
14891
  return new Promise((resolve) => {
14875
14892
  const curTime = this._player.currentTime;
14876
14893
  const _canplay = () => {
14877
- console.log("canplay canplay");
14878
14894
  this._player.currentTime = curTime;
14879
14895
  if (isPaused) {
14880
14896
  this._player.once(CANPLAY, () => {