@volcengine/veplayer 2.6.2 → 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.
Files changed (40) hide show
  1. package/esm/index.d.ts +16 -19
  2. package/esm/veplayer.biz.live.development.css +1 -2
  3. package/esm/veplayer.biz.live.development.js +953 -345
  4. package/esm/veplayer.biz.live.production.css +1 -1
  5. package/esm/veplayer.biz.live.production.js +1 -1
  6. package/esm/veplayer.d.ts +285 -93
  7. package/esm/veplayer.development.css +1 -2
  8. package/esm/veplayer.development.js +912 -332
  9. package/esm/veplayer.live.d.ts +285 -93
  10. package/esm/veplayer.live.development.css +1 -2
  11. package/esm/veplayer.live.development.js +911 -331
  12. package/esm/veplayer.live.production.css +1 -1
  13. package/esm/veplayer.live.production.js +3 -3
  14. package/esm/veplayer.production.css +1 -1
  15. package/esm/veplayer.production.js +3 -3
  16. package/esm/veplayer.vod.d.ts +16 -19
  17. package/esm/veplayer.vod.development.js +36 -20
  18. package/esm/veplayer.vod.production.js +2 -2
  19. package/package.json +1 -1
  20. package/umd/index.d.ts +16 -19
  21. package/umd/veplayer.biz.live.development.css +1 -2
  22. package/umd/veplayer.biz.live.development.js +953 -345
  23. package/umd/veplayer.biz.live.production.css +1 -1
  24. package/umd/veplayer.biz.live.production.js +1 -1
  25. package/umd/veplayer.d.ts +285 -93
  26. package/umd/veplayer.development.css +1 -2
  27. package/umd/veplayer.development.js +912 -332
  28. package/umd/veplayer.live.d.ts +285 -93
  29. package/umd/veplayer.live.development.css +1 -2
  30. package/umd/veplayer.live.development.js +911 -331
  31. package/umd/veplayer.live.production.css +1 -1
  32. package/umd/veplayer.live.production.js +1 -1
  33. package/umd/veplayer.production.css +1 -1
  34. package/umd/veplayer.production.js +1 -1
  35. package/umd/veplayer.vod.d.ts +16 -19
  36. package/umd/veplayer.vod.development.js +36 -20
  37. package/umd/veplayer.vod.production.js +1 -1
  38. package/veplayer.d.ts +285 -93
  39. package/veplayer.live.d.ts +285 -93
  40. package/veplayer.vod.d.ts +16 -19
@@ -1,7 +1,6 @@
1
1
  import Player from "xgplayer";
2
2
  import { IXGI18nText, Plugin, IPluginOptions } from "xgplayer";
3
3
  import { IPlayerOptions as PlayerOptions } from "xgplayer";
4
- import { IDefinition as XGDefinition } from "xgplayer";
5
4
  import { default as Player$0 } from "xgplayer";
6
5
  import { IError as XGError } from "xgplayer";
7
6
  import { IBasePluginOptions as XGPluginOptions } from "xgplayer";
@@ -92,8 +91,8 @@ interface DefinitionUrl {
92
91
  url: string;
93
92
  next: DefinitionUrl | null;
94
93
  }
95
- declare class Definition implements XGDefinition {
96
- readonly definition: string;
94
+ declare class Definition {
95
+ readonly definition?: string;
97
96
  readonly source: Source;
98
97
  readonly text?: Record<Lang, string> | string;
99
98
  readonly fallbackUrl: DefinitionUrl;
@@ -101,7 +100,7 @@ declare class Definition implements XGDefinition {
101
100
  private _currentUrlRef;
102
101
  constructor(definitionSetting: {
103
102
  url: string;
104
- definition: string;
103
+ definition?: string;
105
104
  source: Source;
106
105
  text?: Record<Lang, string> | string;
107
106
  fallbackUrls?: string[];
@@ -139,7 +138,7 @@ interface ExposedDefinition {
139
138
  * @brief The resolution ID. This value must be unique.
140
139
  *
141
140
  */
142
- definition: string;
141
+ definition?: string;
143
142
  /** {zh}
144
143
  * @brief 清晰度展示名称。可设置多语言 `{text: {'zh-cn': '高清', 'en': 'HD'}}`。
145
144
  */
@@ -155,6 +154,7 @@ interface ExposedDefinition {
155
154
  *
156
155
  */
157
156
  fallbackUrls?: string[];
157
+ type?: string;
158
158
  }
159
159
  /** {zh}
160
160
  * @list option
@@ -1482,9 +1482,10 @@ type PrepareResult = {
1482
1482
  options?: Partial<VePlayerBaseOptions>;
1483
1483
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1484
1484
  plugins?: any[];
1485
+ protocol?: string;
1485
1486
  useSrc?: boolean;
1486
1487
  };
1487
- type PreparePlugins = (url: string) => Promise<PrepareResult> | undefined;
1488
+ type PreparePlugins = (url?: string) => Promise<PrepareResult | undefined> | undefined;
1488
1489
  /** {zh}
1489
1490
  * @detail option
1490
1491
  * @brief 视频的实际编码格式。如果您在 degradation 设置了 SoftFirst 属性(即硬解不支持降级软解),建议您传入该参数,省去探测实际编码格式的操作。
@@ -1571,6 +1572,7 @@ declare class VePlayerBase {
1571
1572
  private _events;
1572
1573
  private _customMedia?;
1573
1574
  private _errorCallback;
1575
+ private _beforeFallbackError;
1574
1576
  /** {zh}
1575
1577
  * @hidden
1576
1578
  */
@@ -1721,7 +1723,7 @@ declare class VePlayerBase {
1721
1723
  /** {en}
1722
1724
  * @brief Gets the current resolution ID.
1723
1725
  */
1724
- get definition(): string;
1726
+ get definition(): string | undefined;
1725
1727
  /** {zh}
1726
1728
  * @brief 获取和设置播放器的跨域配置信息,更多信息参考 [crossorigin](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) 属性介绍。
1727
1729
  */
@@ -2333,8 +2335,8 @@ declare namespace strategy {
2333
2335
  next: DefinitionUrl | null;
2334
2336
  }
2335
2337
  function arrayToList(urls?: string[]): DefinitionUrl;
2336
- class Definition implements XGDefinition {
2337
- readonly definition: string;
2338
+ class Definition {
2339
+ readonly definition?: string;
2338
2340
  readonly source: Source;
2339
2341
  readonly text?: Record<Lang, string> | string;
2340
2342
  readonly fallbackUrl: DefinitionUrl;
@@ -2342,7 +2344,7 @@ declare namespace strategy {
2342
2344
  private _currentUrlRef;
2343
2345
  constructor(definitionSetting: {
2344
2346
  url: string;
2345
- definition: string;
2347
+ definition?: string;
2346
2348
  source: Source;
2347
2349
  text?: Record<Lang, string> | string;
2348
2350
  fallbackUrls?: string[];
@@ -2380,7 +2382,7 @@ declare namespace strategy {
2380
2382
  * @brief The resolution ID. This value must be unique.
2381
2383
  *
2382
2384
  */
2383
- definition: string;
2385
+ definition?: string;
2384
2386
  /** {zh}
2385
2387
  * @brief 清晰度展示名称。可设置多语言 `{text: {'zh-cn': '高清', 'en': 'HD'}}`。
2386
2388
  */
@@ -2396,6 +2398,7 @@ declare namespace strategy {
2396
2398
  *
2397
2399
  */
2398
2400
  fallbackUrls?: string[];
2401
+ type?: string;
2399
2402
  }
2400
2403
  /** {zh}
2401
2404
  * @list option
@@ -3783,9 +3786,10 @@ declare namespace strategy {
3783
3786
  options?: Partial<VePlayerBaseOptions>;
3784
3787
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3785
3788
  plugins?: any[];
3789
+ protocol?: string;
3786
3790
  useSrc?: boolean;
3787
3791
  };
3788
- type PreparePlugins = (url: string) => Promise<PrepareResult> | undefined;
3792
+ type PreparePlugins = (url?: string) => Promise<PrepareResult | undefined> | undefined;
3789
3793
  /** {zh}
3790
3794
  * @detail option
3791
3795
  * @brief 视频的实际编码格式。如果您在 degradation 设置了 SoftFirst 属性(即硬解不支持降级软解),建议您传入该参数,省去探测实际编码格式的操作。
@@ -3965,13 +3969,6 @@ declare namespace strategy {
3965
3969
  function detectCodec(url: string): Promise<"unknown" | Codec>;
3966
3970
  function isSoftDecode(options: VePlayerBaseOptions, currentCodec?: Codec | "unknown"): Promise<boolean>;
3967
3971
  function combineOptions<T = VePlayerBaseOptions>(strategyList: (Strategy<T> | undefined)[]): Partial<T>;
3968
- const getHlsStrategy: (options: VePlayerBaseOptions) => Promise<{
3969
- options?: undefined;
3970
- plugins?: undefined;
3971
- } | {
3972
- options: Partial<VePlayerBaseOptions>;
3973
- plugins: any[];
3974
- }>;
3975
3972
  }
3976
3973
  declare namespace error {
3977
3974
  const EN: {
@@ -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 ?? {}
@@ -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.2";
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, () => {