@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.
@@ -11737,14 +11737,6 @@ var __publicField = (obj, key, value) => {
11737
11737
  const sourceManager = args.player.config.sources.sourceManager;
11738
11738
  args.config.list = sourceManager.sources;
11739
11739
  }
11740
- afterCreate() {
11741
- super.afterCreate();
11742
- if (this.config.sourceManager.sources.length < 2) {
11743
- this.hide();
11744
- } else {
11745
- this.renderItemList();
11746
- }
11747
- }
11748
11740
  registerIcons() {
11749
11741
  return {
11750
11742
  source: { icon: SourceIcon }
@@ -11753,6 +11745,10 @@ var __publicField = (obj, key, value) => {
11753
11745
  renderItemList() {
11754
11746
  const { sources, source } = this.config.sourceManager;
11755
11747
  const i18nManager = this.player.config.i18nManager;
11748
+ if (sources.length < 2) {
11749
+ this.hide();
11750
+ return;
11751
+ }
11756
11752
  const renderItems = sources.map((source2) => {
11757
11753
  return {
11758
11754
  ...source2,
@@ -12434,6 +12430,10 @@ var __publicField = (obj, key, value) => {
12434
12430
  var _a, _b;
12435
12431
  const sourceManager = this.player.config.sourceManager;
12436
12432
  const definitions = ((_a = sourceManager.source) == null ? void 0 : _a.definitions) ?? [];
12433
+ if (definitions.length < 2) {
12434
+ this.hide();
12435
+ return;
12436
+ }
12437
12437
  const renderItems = definitions.map((definition) => {
12438
12438
  const showItem = {
12439
12439
  url: definition.url,
@@ -14068,10 +14068,12 @@ var __publicField = (obj, key, value) => {
14068
14068
  __publicField(this, "_events", {});
14069
14069
  __publicField(this, "_customMedia");
14070
14070
  __publicField(this, "_errorCallback");
14071
+ __publicField(this, "_beforeFallbackError");
14071
14072
  var _a, _b, _c, _d, _e, _f;
14072
14073
  this._sourceManager = options.sourceManager;
14073
14074
  this._preparePlugins = options.preparePlugins;
14074
14075
  this._previousPrepareResult = options.prepareResult;
14076
+ this._beforeFallbackError = options.beforeFallbackError;
14075
14077
  this._i18nManager = options.i18nManager ?? new VeI18n({
14076
14078
  i18n: options.i18n
14077
14079
  });
@@ -14096,6 +14098,9 @@ var __publicField = (obj, key, value) => {
14096
14098
  ...DEFAULT_OPTIONS,
14097
14099
  ...xgOptions,
14098
14100
  definition: {
14101
+ // TODO: ts
14102
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14103
+ // @ts-ignore
14099
14104
  list: ((_d = this._sourceManager.source) == null ? void 0 : _d.definitions) ?? [],
14100
14105
  defaultDefinition: (_e = this._sourceManager.definition) == null ? void 0 : _e.definition,
14101
14106
  ...options.definition ?? {}
@@ -14154,7 +14159,7 @@ var __publicField = (obj, key, value) => {
14154
14159
  return this._player.played;
14155
14160
  }
14156
14161
  /** {zh}
14157
- * @brief 设置/获取视频当前的播放时间, 单位为 s。
14162
+ * @brief 设置/获取视频当前的播放时间,单位为 s。
14158
14163
  */
14159
14164
  /** {en}
14160
14165
  * @brief Sets or gets the current playback position of the video, in seconds.
@@ -14280,7 +14285,7 @@ var __publicField = (obj, key, value) => {
14280
14285
  * @brief Retrieve the player SDK version number.
14281
14286
  */
14282
14287
  get playerVersion() {
14283
- return "2.6.1";
14288
+ return "2.7.0-rc.0";
14284
14289
  }
14285
14290
  /** {zh}
14286
14291
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -14766,13 +14771,18 @@ var __publicField = (obj, key, value) => {
14766
14771
  * @hidden
14767
14772
  */
14768
14773
  async prepare(url) {
14769
- var _a, _b, _c, _d, _e, _f, _g;
14774
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
14770
14775
  const result = await ((_a = this._preparePlugins) == null ? void 0 : _a.call(this, url));
14771
- const newUrl = ((_b = result == null ? void 0 : result.options) == null ? void 0 : _b.url) ?? url;
14772
- const oldUrl = (_d = (_c = this._player) == null ? void 0 : _c.config) == null ? void 0 : _d.url;
14773
- const isSameProtocol = oldUrl && getStreamType(newUrl) === getStreamType(oldUrl);
14776
+ let isSameProtocol;
14777
+ if ((result == null ? void 0 : result.protocol) && ((_b = this._previousPrepareResult) == null ? void 0 : _b.protocol)) {
14778
+ isSameProtocol = result.protocol === ((_c = this._previousPrepareResult) == null ? void 0 : _c.protocol);
14779
+ } else {
14780
+ const newUrl = ((_d = result == null ? void 0 : result.options) == null ? void 0 : _d.url) ?? url;
14781
+ const oldUrl = (_f = (_e = this._player) == null ? void 0 : _e.config) == null ? void 0 : _f.url;
14782
+ isSameProtocol = oldUrl && getStreamType(newUrl) === getStreamType(oldUrl);
14783
+ }
14774
14784
  if (!isSameProtocol) {
14775
- (_f = (_e = this._previousPrepareResult) == null ? void 0 : _e.plugins) == null ? void 0 : _f.forEach((plugin) => {
14785
+ (_h = (_g = this._previousPrepareResult) == null ? void 0 : _g.plugins) == null ? void 0 : _h.forEach((plugin) => {
14776
14786
  this._player.unRegisterPlugin(plugin.pluginName);
14777
14787
  });
14778
14788
  }
@@ -14781,7 +14791,7 @@ var __publicField = (obj, key, value) => {
14781
14791
  this._player.setConfig(result.options);
14782
14792
  }
14783
14793
  return {
14784
- plugins: isSameProtocol ? [] : (_g = result == null ? void 0 : result.plugins) == null ? void 0 : _g.map((plugin) => {
14794
+ plugins: isSameProtocol ? [] : (_i = result == null ? void 0 : result.plugins) == null ? void 0 : _i.map((plugin) => {
14785
14795
  return this._player.registerPlugin(plugin);
14786
14796
  }),
14787
14797
  options: result == null ? void 0 : result.options,
@@ -14794,11 +14804,18 @@ var __publicField = (obj, key, value) => {
14794
14804
  const preUrl = this._sourceManager.url;
14795
14805
  const url = this._sourceManager.fallback();
14796
14806
  if (!url) {
14807
+ const transformedError = transform$1(err, this._i18nManager);
14808
+ try {
14809
+ const { canEmitError } = await this._beforeFallbackError(
14810
+ transformedError
14811
+ );
14812
+ if (!canEmitError) {
14813
+ return;
14814
+ }
14815
+ } catch (error2) {
14816
+ }
14797
14817
  this._player.removeClass(STATE_CLASS.ENTER);
14798
- this.emit(
14799
- Events.FALLBACK_ERROR,
14800
- transform$1(err, this._i18nManager)
14801
- );
14818
+ this.emit(Events.FALLBACK_ERROR, transformedError);
14802
14819
  return;
14803
14820
  }
14804
14821
  this._player.once("canplay", () => {
@@ -14878,7 +14895,6 @@ var __publicField = (obj, key, value) => {
14878
14895
  return new Promise((resolve) => {
14879
14896
  const curTime = this._player.currentTime;
14880
14897
  const _canplay = () => {
14881
- console.log("canplay canplay");
14882
14898
  this._player.currentTime = curTime;
14883
14899
  if (isPaused) {
14884
14900
  this._player.once(CANPLAY, () => {