@volcengine/veplayer 2.6.2 → 2.7.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.
@@ -1,7 +1,6 @@
1
1
  import Player from "xgplayer";
2
2
  import { IXGI18nText, Plugin, IPluginOptions, Sniffer } 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";
@@ -164,8 +163,8 @@ interface DefinitionUrl {
164
163
  url: string;
165
164
  next: DefinitionUrl | null;
166
165
  }
167
- declare class Definition implements XGDefinition {
168
- readonly definition: string;
166
+ declare class Definition {
167
+ readonly definition?: string;
169
168
  readonly source: Source;
170
169
  readonly text?: Record<Lang, string> | string;
171
170
  readonly fallbackUrl: DefinitionUrl;
@@ -173,7 +172,7 @@ declare class Definition implements XGDefinition {
173
172
  private _currentUrlRef;
174
173
  constructor(definitionSetting: {
175
174
  url: string;
176
- definition: string;
175
+ definition?: string;
177
176
  source: Source;
178
177
  text?: Record<Lang, string> | string;
179
178
  fallbackUrls?: string[];
@@ -211,7 +210,7 @@ interface ExposedDefinition {
211
210
  * @brief The resolution ID. This value must be unique.
212
211
  *
213
212
  */
214
- definition: string;
213
+ definition?: string;
215
214
  /** {zh}
216
215
  * @brief 清晰度展示名称。可设置多语言 `{text: {'zh-cn': '高清', 'en': 'HD'}}`。
217
216
  */
@@ -227,6 +226,7 @@ interface ExposedDefinition {
227
226
  *
228
227
  */
229
228
  fallbackUrls?: string[];
229
+ type?: string;
230
230
  }
231
231
  /** {zh}
232
232
  * @list option
@@ -1613,9 +1613,10 @@ type PrepareResult = {
1613
1613
  options?: Partial<VePlayerBaseOptions>;
1614
1614
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1615
1615
  plugins?: any[];
1616
+ protocol?: string;
1616
1617
  useSrc?: boolean;
1617
1618
  };
1618
- type PreparePlugins = (url: string) => Promise<PrepareResult> | undefined;
1619
+ type PreparePlugins = (url?: string) => Promise<PrepareResult | undefined> | undefined;
1619
1620
  /** {zh}
1620
1621
  * @detail option
1621
1622
  * @brief 视频的实际编码格式。如果您在 degradation 设置了 SoftFirst 属性(即硬解不支持降级软解),建议您传入该参数,省去探测实际编码格式的操作。
@@ -1739,6 +1740,7 @@ declare class VePlayerBase {
1739
1740
  private _events;
1740
1741
  private _customMedia?;
1741
1742
  private _errorCallback;
1743
+ private _beforeFallbackError;
1742
1744
  /** {zh}
1743
1745
  * @hidden
1744
1746
  */
@@ -1889,7 +1891,7 @@ declare class VePlayerBase {
1889
1891
  /** {en}
1890
1892
  * @brief Gets the current resolution ID.
1891
1893
  */
1892
- get definition(): string;
1894
+ get definition(): string | undefined;
1893
1895
  /** {zh}
1894
1896
  * @brief 获取和设置播放器的跨域配置信息,更多信息参考 [crossorigin](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) 属性介绍。
1895
1897
  */
@@ -2506,8 +2508,8 @@ declare namespace strategy {
2506
2508
  next: DefinitionUrl | null;
2507
2509
  }
2508
2510
  function arrayToList(urls?: string[]): DefinitionUrl;
2509
- class Definition implements XGDefinition {
2510
- readonly definition: string;
2511
+ class Definition {
2512
+ readonly definition?: string;
2511
2513
  readonly source: Source;
2512
2514
  readonly text?: Record<Lang, string> | string;
2513
2515
  readonly fallbackUrl: DefinitionUrl;
@@ -2515,7 +2517,7 @@ declare namespace strategy {
2515
2517
  private _currentUrlRef;
2516
2518
  constructor(definitionSetting: {
2517
2519
  url: string;
2518
- definition: string;
2520
+ definition?: string;
2519
2521
  source: Source;
2520
2522
  text?: Record<Lang, string> | string;
2521
2523
  fallbackUrls?: string[];
@@ -2553,7 +2555,7 @@ declare namespace strategy {
2553
2555
  * @brief The resolution ID. This value must be unique.
2554
2556
  *
2555
2557
  */
2556
- definition: string;
2558
+ definition?: string;
2557
2559
  /** {zh}
2558
2560
  * @brief 清晰度展示名称。可设置多语言 `{text: {'zh-cn': '高清', 'en': 'HD'}}`。
2559
2561
  */
@@ -2569,6 +2571,7 @@ declare namespace strategy {
2569
2571
  *
2570
2572
  */
2571
2573
  fallbackUrls?: string[];
2574
+ type?: string;
2572
2575
  }
2573
2576
  /** {zh}
2574
2577
  * @list option
@@ -3956,9 +3959,10 @@ declare namespace strategy {
3956
3959
  options?: Partial<VePlayerBaseOptions>;
3957
3960
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3958
3961
  plugins?: any[];
3962
+ protocol?: string;
3959
3963
  useSrc?: boolean;
3960
3964
  };
3961
- type PreparePlugins = (url: string) => Promise<PrepareResult> | undefined;
3965
+ type PreparePlugins = (url?: string) => Promise<PrepareResult | undefined> | undefined;
3962
3966
  /** {zh}
3963
3967
  * @detail option
3964
3968
  * @brief 视频的实际编码格式。如果您在 degradation 设置了 SoftFirst 属性(即硬解不支持降级软解),建议您传入该参数,省去探测实际编码格式的操作。
@@ -4138,13 +4142,6 @@ declare namespace strategy {
4138
4142
  function detectCodec(url: string): Promise<"unknown" | Codec>;
4139
4143
  function isSoftDecode(options: VePlayerBaseOptions, currentCodec?: Codec | "unknown"): Promise<boolean>;
4140
4144
  function combineOptions<T = VePlayerBaseOptions>(strategyList: (Strategy<T> | undefined)[]): Partial<T>;
4141
- const getHlsStrategy: (options: VePlayerBaseOptions) => Promise<{
4142
- options?: undefined;
4143
- plugins?: undefined;
4144
- } | {
4145
- options: Partial<VePlayerBaseOptions>;
4146
- plugins: any[];
4147
- }>;
4148
4145
  }
4149
4146
  declare function getStreamType(url: string): "unknown" | "hls" | "flv" | "rtm" | "mp4" | "dash";
4150
4147
  /** {zh}
@@ -5068,7 +5065,6 @@ declare class Sources extends OptionsIcon {
5068
5065
  };
5069
5066
  updateLang(): void;
5070
5067
  beforeCreate(args: XGPluginOptions): void;
5071
- afterCreate(): void;
5072
5068
  registerIcons(): {
5073
5069
  source: {
5074
5070
  icon: any;
@@ -5241,6 +5237,88 @@ interface LoggerConfig {
5241
5237
  */
5242
5238
  showUserIdInErrorPanel?: boolean;
5243
5239
  }
5240
+ declare enum FallbackKind {
5241
+ Error = "Error",
5242
+ Stall = "Stall"
5243
+ }
5244
+ interface ErrorFallbackStrategy {
5245
+ type?: FallbackKind;
5246
+ excludeList?: ErrorCode[];
5247
+ shouldFallback?: (type: string, params: {
5248
+ error: VeError;
5249
+ }) => boolean;
5250
+ }
5251
+ interface StallFallbackStrategy {
5252
+ type?: FallbackKind;
5253
+ shouldFallback?: (type: string) => boolean;
5254
+ }
5255
+ // 播放类型抽象类 (BaseProtocol)
5256
+ declare abstract class BaseProtocol {
5257
+ // 下一个 protocol 类
5258
+ nextProtocol?: BaseProtocol;
5259
+ preProtocol?: BaseProtocol;
5260
+ protocolStrategy?: Strategy;
5261
+ private _fallback;
5262
+ constructor(options: VePlayerBaseOptions);
5263
+ // 当前播放类型
5264
+ abstract get protocolType(): string;
5265
+ abstract get defaultFallbackStrategy(): Partial<Record<FallbackKind, StallFallbackStrategy | ErrorFallbackStrategy>>;
5266
+ private _getKindFallbackStrategy;
5267
+ // eslint-disable-next-line @typescript-eslint/member-ordering
5268
+ get errorFallbackStrategy(): any;
5269
+ // eslint-disable-next-line @typescript-eslint/member-ordering
5270
+ get stallFallbackStrategy(): any;
5271
+ abstract shouldFallbackWhenStall(): boolean;
5272
+ // eslint-disable-next-line @typescript-eslint/member-ordering
5273
+ shouldFallbackWhenError(params: {
5274
+ error: VeError;
5275
+ }): any;
5276
+ // 是否支持播放
5277
+ abstract canPlay(): Promise<{
5278
+ canPlay: boolean;
5279
+ }>;
5280
+ abstract getProtocolStrategy(options: VePlayerBaseOptions, config?: {
5281
+ player?: VePlayerBase;
5282
+ i18n?: VeI18n;
5283
+ enableSelector?: boolean;
5284
+ }): Promise<Strategy> | undefined;
5285
+ abstract getDrmStrategy(options: VePlayerBaseOptions, player?: VePlayerBase): Promise<Strategy> | undefined;
5286
+ abstract getAbrStrategy(options: VePlayerBaseOptions): Promise<Strategy> | undefined;
5287
+ }
5288
+ type Strategy = {
5289
+ options?: undefined;
5290
+ plugins?: undefined;
5291
+ } | {
5292
+ options: Partial<VePlayerBaseOptions>;
5293
+ plugins: any[];
5294
+ };
5295
+ declare class ProtocolManager {
5296
+ private static _protocolMap;
5297
+ private _options;
5298
+ private _selector?;
5299
+ private _protocol;
5300
+ private _playlistMap;
5301
+ constructor(options: LiveVePlayerOptions);
5302
+ get enableSelector(): boolean;
5303
+ get protocol(): BaseProtocol | undefined;
5304
+ get playlist(): ExposedSource[] | undefined;
5305
+ static create(options: LiveVePlayerOptions): Promise<ProtocolManager>;
5306
+ private static _generateProtocolMap;
5307
+ getProtocol(): Promise<BaseProtocol | undefined>;
5308
+ update({ url, playlist }: {
5309
+ url?: string;
5310
+ playlist?: VePlayerBaseOptions["playlist"];
5311
+ }): Promise<void>;
5312
+ next(): Promise<BaseProtocol | undefined>;
5313
+ getStrategy(player: VePlayerBase | undefined, i18n: VeI18n): Promise<{
5314
+ options: Partial<VePlayerBaseOptions>;
5315
+ plugins: any[];
5316
+ useSrc: boolean;
5317
+ protocol: string | undefined;
5318
+ }>;
5319
+ private _init;
5320
+ private _initSingleProtocol;
5321
+ }
5244
5322
  /** {zh}
5245
5323
  * @list option
5246
5324
  * @kind property
@@ -5333,6 +5411,16 @@ interface LiveVePlayerOptions extends VePlayerBaseOptions {
5333
5411
  * @brief Digital Rights Management (DRM) configurations.
5334
5412
  */
5335
5413
  drm?: Drm;
5414
+ latencyMode?: "standard" | "low";
5415
+ fallback?: Fallback;
5416
+ }
5417
+ interface Fallback {
5418
+ enableFallback?: boolean;
5419
+ fallbackOrder?: string[];
5420
+ fallbackStrategy?: Record<string | "all", {
5421
+ [FallbackKind.Error]?: ErrorFallbackStrategy;
5422
+ [FallbackKind.Stall]?: StallFallbackStrategy;
5423
+ }>;
5336
5424
  }
5337
5425
  /** {zh}
5338
5426
  * @list option
@@ -6394,6 +6482,7 @@ interface FlvStats extends Stats$0 {
6394
6482
  * @inheritdoc
6395
6483
  */
6396
6484
  declare class VePlayerLive extends VePlayerBase {
6485
+ _protocolManager?: ProtocolManager;
6397
6486
  /** {zh}
6398
6487
  * @hidden
6399
6488
  * @param options
@@ -6531,6 +6620,28 @@ declare class VePlayerLive extends VePlayerBase {
6531
6620
  * @brief Obtain the playback information of HLS pull streaming.
6532
6621
  */
6533
6622
  getHLSStats(): Stats$0;
6623
+ updatePlaylist(playlist: ExposedSource[], target?: string | {
6624
+ /** {zh}
6625
+ * @brief 清晰度唯一标识。
6626
+ * @default 无
6627
+ *
6628
+ */
6629
+ /** {en}
6630
+ * @brief The resolution ID.
6631
+ *
6632
+ */
6633
+ definition?: string;
6634
+ /** {zh}
6635
+ * @brief 线路的唯一标识。
6636
+ * @default 无
6637
+ *
6638
+ */
6639
+ /** {en}
6640
+ * @brief The playback resource ID.
6641
+ *
6642
+ */
6643
+ source?: string;
6644
+ }, needUpdateProtocol?: boolean): Promise<void>;
6534
6645
  }
6535
6646
  /** {zh}
6536
6647
  * @detail api
@@ -7219,8 +7330,8 @@ declare namespace live {
7219
7330
  next: DefinitionUrl | null;
7220
7331
  }
7221
7332
  function arrayToList(urls?: string[]): DefinitionUrl;
7222
- class Definition implements XGDefinition {
7223
- readonly definition: string;
7333
+ class Definition {
7334
+ readonly definition?: string;
7224
7335
  readonly source: Source;
7225
7336
  readonly text?: Record<Lang, string> | string;
7226
7337
  readonly fallbackUrl: DefinitionUrl;
@@ -7228,7 +7339,7 @@ declare namespace live {
7228
7339
  private _currentUrlRef;
7229
7340
  constructor(definitionSetting: {
7230
7341
  url: string;
7231
- definition: string;
7342
+ definition?: string;
7232
7343
  source: Source;
7233
7344
  text?: Record<Lang, string> | string;
7234
7345
  fallbackUrls?: string[];
@@ -7266,7 +7377,7 @@ declare namespace live {
7266
7377
  * @brief The resolution ID. This value must be unique.
7267
7378
  *
7268
7379
  */
7269
- definition: string;
7380
+ definition?: string;
7270
7381
  /** {zh}
7271
7382
  * @brief 清晰度展示名称。可设置多语言 `{text: {'zh-cn': '高清', 'en': 'HD'}}`。
7272
7383
  */
@@ -7282,6 +7393,7 @@ declare namespace live {
7282
7393
  *
7283
7394
  */
7284
7395
  fallbackUrls?: string[];
7396
+ type?: string;
7285
7397
  }
7286
7398
  /** {zh}
7287
7399
  * @list option
@@ -9270,9 +9382,10 @@ declare namespace live {
9270
9382
  options?: Partial<VePlayerBaseOptions>;
9271
9383
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9272
9384
  plugins?: any[];
9385
+ protocol?: string;
9273
9386
  useSrc?: boolean;
9274
9387
  };
9275
- type PreparePlugins = (url: string) => Promise<PrepareResult> | undefined;
9388
+ type PreparePlugins = (url?: string) => Promise<PrepareResult | undefined> | undefined;
9276
9389
  /** {zh}
9277
9390
  * @detail option
9278
9391
  * @brief 视频的实际编码格式。如果您在 degradation 设置了 SoftFirst 属性(即硬解不支持降级软解),建议您传入该参数,省去探测实际编码格式的操作。
@@ -9397,6 +9510,7 @@ declare namespace live {
9397
9510
  private _events;
9398
9511
  private _customMedia?;
9399
9512
  private _errorCallback;
9513
+ private _beforeFallbackError;
9400
9514
  /** {zh}
9401
9515
  * @hidden
9402
9516
  */
@@ -9547,7 +9661,7 @@ declare namespace live {
9547
9661
  /** {en}
9548
9662
  * @brief Gets the current resolution ID.
9549
9663
  */
9550
- get definition(): string;
9664
+ get definition(): string | undefined;
9551
9665
  /** {zh}
9552
9666
  * @brief 获取和设置播放器的跨域配置信息,更多信息参考 [crossorigin](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) 属性介绍。
9553
9667
  */
@@ -10253,7 +10367,6 @@ declare namespace live {
10253
10367
  };
10254
10368
  updateLang(): void;
10255
10369
  beforeCreate(args: XGPluginOptions): void;
10256
- afterCreate(): void;
10257
10370
  registerIcons(): {
10258
10371
  source: {
10259
10372
  icon: any;
@@ -10762,6 +10875,88 @@ declare namespace live {
10762
10875
  private _createTea;
10763
10876
  private _start;
10764
10877
  }
10878
+ enum FallbackKind {
10879
+ Error = "Error",
10880
+ Stall = "Stall"
10881
+ }
10882
+ interface ErrorFallbackStrategy {
10883
+ type?: FallbackKind;
10884
+ excludeList?: ErrorCode$0[];
10885
+ shouldFallback?: (type: string, params: {
10886
+ error: VeError$1;
10887
+ }) => boolean;
10888
+ }
10889
+ interface StallFallbackStrategy {
10890
+ type?: FallbackKind;
10891
+ shouldFallback?: (type: string) => boolean;
10892
+ }
10893
+ // 播放类型抽象类 (BaseProtocol)
10894
+ abstract class BaseProtocol {
10895
+ // 下一个 protocol 类
10896
+ nextProtocol?: BaseProtocol;
10897
+ preProtocol?: BaseProtocol;
10898
+ protocolStrategy?: Strategy;
10899
+ private _fallback;
10900
+ constructor(options: VePlayerBaseOptions);
10901
+ // 当前播放类型
10902
+ abstract get protocolType(): string;
10903
+ abstract get defaultFallbackStrategy(): Partial<Record<FallbackKind, StallFallbackStrategy | ErrorFallbackStrategy>>;
10904
+ private _getKindFallbackStrategy;
10905
+ // eslint-disable-next-line @typescript-eslint/member-ordering
10906
+ get errorFallbackStrategy(): any;
10907
+ // eslint-disable-next-line @typescript-eslint/member-ordering
10908
+ get stallFallbackStrategy(): any;
10909
+ abstract shouldFallbackWhenStall(): boolean;
10910
+ // eslint-disable-next-line @typescript-eslint/member-ordering
10911
+ shouldFallbackWhenError(params: {
10912
+ error: VeError$1;
10913
+ }): any;
10914
+ // 是否支持播放
10915
+ abstract canPlay(): Promise<{
10916
+ canPlay: boolean;
10917
+ }>;
10918
+ abstract getProtocolStrategy(options: VePlayerBaseOptions, config?: {
10919
+ player?: VePlayerBase;
10920
+ i18n?: VeI18n;
10921
+ enableSelector?: boolean;
10922
+ }): Promise<Strategy> | undefined;
10923
+ abstract getDrmStrategy(options: VePlayerBaseOptions, player?: VePlayerBase): Promise<Strategy> | undefined;
10924
+ abstract getAbrStrategy(options: VePlayerBaseOptions): Promise<Strategy> | undefined;
10925
+ }
10926
+ type Strategy = {
10927
+ options?: undefined;
10928
+ plugins?: undefined;
10929
+ } | {
10930
+ options: Partial<VePlayerBaseOptions>;
10931
+ plugins: any[];
10932
+ };
10933
+ class ProtocolManager {
10934
+ private static _protocolMap;
10935
+ private _options;
10936
+ private _selector?;
10937
+ private _protocol;
10938
+ private _playlistMap;
10939
+ constructor(options: LiveVePlayerOptions);
10940
+ get enableSelector(): boolean;
10941
+ get protocol(): BaseProtocol | undefined;
10942
+ get playlist(): ExposedSource[] | undefined;
10943
+ static create(options: LiveVePlayerOptions): Promise<ProtocolManager>;
10944
+ private static _generateProtocolMap;
10945
+ getProtocol(): Promise<BaseProtocol | undefined>;
10946
+ update({ url, playlist }: {
10947
+ url?: string;
10948
+ playlist?: VePlayerBaseOptions["playlist"];
10949
+ }): Promise<void>;
10950
+ next(): Promise<BaseProtocol | undefined>;
10951
+ getStrategy(player: VePlayerBase | undefined, i18n: VeI18n): Promise<{
10952
+ options: Partial<VePlayerBaseOptions>;
10953
+ plugins: any[];
10954
+ useSrc: boolean;
10955
+ protocol: string | undefined;
10956
+ }>;
10957
+ private _init;
10958
+ private _initSingleProtocol;
10959
+ }
10765
10960
  /** {zh}
10766
10961
  * @list option
10767
10962
  * @kind property
@@ -10854,6 +11049,16 @@ declare namespace live {
10854
11049
  * @brief Digital Rights Management (DRM) configurations.
10855
11050
  */
10856
11051
  drm?: Drm;
11052
+ latencyMode?: "standard" | "low";
11053
+ fallback?: Fallback;
11054
+ }
11055
+ interface Fallback {
11056
+ enableFallback?: boolean;
11057
+ fallbackOrder?: string[];
11058
+ fallbackStrategy?: Record<string | "all", {
11059
+ [FallbackKind.Error]?: ErrorFallbackStrategy;
11060
+ [FallbackKind.Stall]?: StallFallbackStrategy;
11061
+ }>;
10857
11062
  }
10858
11063
  /** {zh}
10859
11064
  * @list option
@@ -11915,6 +12120,7 @@ declare namespace live {
11915
12120
  * @inheritdoc
11916
12121
  */
11917
12122
  class VePlayerLive extends VePlayerBase {
12123
+ _protocolManager?: ProtocolManager;
11918
12124
  /** {zh}
11919
12125
  * @hidden
11920
12126
  * @param options
@@ -12052,6 +12258,28 @@ declare namespace live {
12052
12258
  * @brief Obtain the playback information of HLS pull streaming.
12053
12259
  */
12054
12260
  getHLSStats(): Stats$0;
12261
+ updatePlaylist(playlist: ExposedSource[], target?: string | {
12262
+ /** {zh}
12263
+ * @brief 清晰度唯一标识。
12264
+ * @default 无
12265
+ *
12266
+ */
12267
+ /** {en}
12268
+ * @brief The resolution ID.
12269
+ *
12270
+ */
12271
+ definition?: string;
12272
+ /** {zh}
12273
+ * @brief 线路的唯一标识。
12274
+ * @default 无
12275
+ *
12276
+ */
12277
+ /** {en}
12278
+ * @brief The playback resource ID.
12279
+ *
12280
+ */
12281
+ source?: string;
12282
+ }, needUpdateProtocol?: boolean): Promise<void>;
12055
12283
  }
12056
12284
  /** {zh}
12057
12285
  * @detail api