@volcengine/veplayer 1.19.0-rc.1 → 1.19.0-rc.11

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.
package/lite.d.ts CHANGED
@@ -85,7 +85,7 @@ interface ISubTitleItem {
85
85
  * @brief Subtitle display name.
86
86
  * @default -
87
87
  */
88
- text?: string;
88
+ text?: ISubtitleLabelValue;
89
89
  /** {zh}
90
90
  * @brief 字幕名称。兼容 xgplayer-subtitles 的 label 字段。
91
91
  * @default -
@@ -94,7 +94,7 @@ interface ISubTitleItem {
94
94
  * @brief 字幕名称。兼容 xgplayer-subtitles 的 label 字段。
95
95
  * @default -
96
96
  */
97
- label?: string | number;
97
+ label?: ISubtitleLabelValue;
98
98
  /** {zh}
99
99
  * @brief 外挂字幕 URL 地址。
100
100
  * @default -
@@ -124,6 +124,118 @@ interface ISubTitleItem {
124
124
  */
125
125
  list?: IListItem[];
126
126
  }
127
+ /** {zh}
128
+ * @brief 字幕项名称,可为静态文案或按播放器语言配置的文案表。
129
+ * @detail ref
130
+ */
131
+ /** {en}
132
+ * @brief Subtitle item name as static text or a text map keyed by player language.
133
+ * @detail ref
134
+ */
135
+ export type ISubtitleLabelValue = string | number | Record<string, string | number>;
136
+ /** {zh}
137
+ * @brief 字幕标签映射项。
138
+ * @detail ref
139
+ */
140
+ /** {en}
141
+ * @brief Mapping item used to customize a subtitle label.
142
+ * @detail ref
143
+ */
144
+ export interface ISubtitleLabelItem {
145
+ /** {zh} @brief 多语言 key 无法解析时使用的回退文案。 */
146
+ /** {en} @brief Fallback text used when the i18n key cannot be resolved. */
147
+ text?: string;
148
+ /** {zh} @brief 从播放器当前多语言词典中读取文案的 key。 */
149
+ /** {en} @brief Key resolved from the player's active i18n dictionary. */
150
+ textKey?: string;
151
+ }
152
+ /** {zh}
153
+ * @brief 字幕标签映射表。匹配优先级为 `id`、完整 `language`、基础 `language`、原始 `text`。
154
+ * @detail ref
155
+ */
156
+ /** {en}
157
+ * @brief Subtitle label maps. Match order is `id`, full `language`, base `language`, then source `text`.
158
+ * @detail ref
159
+ */
160
+ export interface ISubtitleLabelMap {
161
+ /** {zh} @brief 按稳定字幕 ID 映射;不建议用于会话内生成 ID 的 Master M3U8 字幕。 */
162
+ /** {en} @brief Maps stable subtitle IDs; not recommended for session-scoped Master M3U8 IDs. */
163
+ id?: Record<string, ISubtitleLabelItem>;
164
+ /** {zh} @brief 按字幕语言映射,忽略大小写并兼容 `_` 与 `-`。 */
165
+ /** {en} @brief Maps subtitle languages case-insensitively, treating `_` and `-` as equivalent. */
166
+ language?: Record<string, ISubtitleLabelItem>;
167
+ /** {zh} @brief 按字幕原始名称映射。 */
168
+ /** {en} @brief Maps the source subtitle name. */
169
+ text?: Record<string, ISubtitleLabelItem>;
170
+ }
171
+ /** {zh}
172
+ * @brief 传给字幕标签 formatter 的只读安全字幕快照,不包含 URL 或字幕内容。
173
+ * @detail ref
174
+ */
175
+ /** {en}
176
+ * @brief Read-only safe subtitle snapshot passed to the label formatter, excluding URLs and subtitle content.
177
+ * @detail ref
178
+ */
179
+ export interface ISubtitleLabelTrack {
180
+ source?: "config" | "hls";
181
+ id?: string | number;
182
+ language?: string | number;
183
+ isDefault?: boolean;
184
+ forced?: boolean;
185
+ characteristics?: string;
186
+ text?: string | number;
187
+ label?: string | number;
188
+ }
189
+ /** {zh}
190
+ * @brief 字幕标签格式化上下文。
191
+ * @detail ref
192
+ */
193
+ /** {en}
194
+ * @brief Context passed to the subtitle label formatter.
195
+ * @detail ref
196
+ */
197
+ export interface ISubtitleLabelContext {
198
+ /** {zh} @brief 当前字幕项的只读安全快照。 */
199
+ /** {en} @brief Read-only safe snapshot of the current subtitle item. */
200
+ item: Readonly<ISubtitleLabelTrack>;
201
+ /** {zh} @brief 当前字幕列表的只读安全快照。 */
202
+ /** {en} @brief Read-only safe snapshots of the current subtitle list. */
203
+ items: ReadonlyArray<Readonly<ISubtitleLabelTrack>>;
204
+ /** {zh} @brief 当前字幕项在列表中的位置。 */
205
+ /** {en} @brief Position of the current subtitle item in the list. */
206
+ index: number;
207
+ /** {zh} @brief 应用标签映射前的原始回退文案。 */
208
+ /** {en} @brief Source fallback text before applying label mappings. */
209
+ canonicalLabel: string;
210
+ /** {zh} @brief 应用 `textKey` 或 `text` 后的文案。 */
211
+ /** {en} @brief Label after applying `textKey` or `text`. */
212
+ localizedLabel: string;
213
+ /** {zh} @brief formatter 返回空值或抛出异常时使用的文案。 */
214
+ /** {en} @brief Label used when the formatter returns an empty value or throws. */
215
+ defaultLabel: string;
216
+ /** {zh} @brief 播放器当前语言。 */
217
+ /** {en} @brief Current player language. */
218
+ lang: string;
219
+ /** {zh} @brief 本地化后的文案是否在当前字幕列表中重复。 */
220
+ /** {en} @brief Whether the localized label is duplicated in the current subtitle list. */
221
+ duplicated: boolean;
222
+ }
223
+ /** {zh}
224
+ * @brief 字幕标签多语言映射与自定义格式化配置。
225
+ * @detail ref
226
+ */
227
+ /** {en}
228
+ * @brief Localization mapping and custom formatter for subtitle labels.
229
+ * @detail ref
230
+ */
231
+ export interface ISubtitleLabelOptions {
232
+ /** {zh} @brief 按字幕 ID、语言或原始名称配置展示文案。 */
233
+ /** {en} @brief Display-label mappings keyed by subtitle ID, language, or source name. */
234
+ map?: ISubtitleLabelMap;
235
+ /** {zh} @brief 同步格式化最终标签;返回空值、Promise 或抛出异常时回退到 `defaultLabel`。 */
236
+ /** {en} @brief Synchronously formats the final label; empty values, Promises, or exceptions fall back to `defaultLabel`. */
237
+ formatter?: (context: ISubtitleLabelContext) => string | null | undefined;
238
+ }
127
239
  interface IListItem {
128
240
  /** {zh}
129
241
  * @brief 开始时间,单位为秒。
@@ -417,6 +529,92 @@ export interface IHlsLevel {
417
529
  /** {en} @brief Level name declared by the manifest. */
418
530
  name?: string;
419
531
  }
532
+ /** {zh}
533
+ * @brief HLS Level 标签映射项。
534
+ * @detail ref
535
+ */
536
+ /** {en}
537
+ * @brief Mapping item used to customize an HLS Level label.
538
+ * @detail ref
539
+ */
540
+ export interface IHlsLevelLabelItem {
541
+ /** {zh} @brief 当多语言 key 无法解析时使用的回退文案。 */
542
+ /** {en} @brief Fallback text used when the i18n key cannot be resolved. */
543
+ text?: string;
544
+ /** {zh} @brief 从播放器当前多语言词典中读取文案的 key。 */
545
+ /** {en} @brief Key resolved from the player's active i18n dictionary. */
546
+ textKey?: string;
547
+ }
548
+ /** {zh}
549
+ * @brief HLS Level 标签格式化上下文。
550
+ * @detail ref
551
+ */
552
+ /** {en}
553
+ * @brief Context passed to the HLS Level label formatter.
554
+ * @detail ref
555
+ */
556
+ export interface IHlsLevelLabelContext {
557
+ /** {zh} @brief 当前 Level 的只读安全快照。 */
558
+ /** {en} @brief Read-only safe snapshot of the current Level. */
559
+ level: Readonly<IHlsLevel>;
560
+ /** {zh} @brief 当前播放会话全部 Level 的只读安全快照。 */
561
+ /** {en} @brief Read-only safe snapshots of all Levels in the current playback session. */
562
+ levels: ReadonlyArray<Readonly<IHlsLevel>>;
563
+ /** {zh} @brief 视频短边像素值;Manifest 未提供分辨率时为空。 */
564
+ /** {en} @brief Video short edge in pixels, or undefined when dimensions are unavailable. */
565
+ shortEdge?: number;
566
+ /** {zh} @brief 未本地化、未消歧的标准标签。 */
567
+ /** {en} @brief Canonical label before localization and disambiguation. */
568
+ canonicalLabel: string;
569
+ /** {zh} @brief 应用 `textKey` 或 `text` 后的基础标签。 */
570
+ /** {en} @brief Base label after applying `textKey` or `text`. */
571
+ localizedLabel: string;
572
+ /** {zh} @brief 完成 SDK 默认重名消歧后的标签。 */
573
+ /** {en} @brief Label after the SDK's default duplicate disambiguation. */
574
+ defaultLabel: string;
575
+ /** {zh} @brief 播放器当前语言。 */
576
+ /** {en} @brief Current player language. */
577
+ lang: string;
578
+ /** {zh} @brief 当前标准标签是否在 Level 列表中重复。 */
579
+ /** {en} @brief Whether the canonical label is duplicated in the Level list. */
580
+ duplicated: boolean;
581
+ }
582
+ /** {zh}
583
+ * @brief HLS Level 标签的多语言映射与自定义格式化配置。
584
+ * @detail ref
585
+ * @example
586
+ * ``` javascript
587
+ * hlsLevelLabel: {
588
+ * map: {
589
+ * '720p': { textKey: 'HLS_LEVEL_HD', text: '720p' }
590
+ * },
591
+ * formatter: ({ defaultLabel, level }) =>
592
+ * level.videoRange === 'PQ' ? `${defaultLabel} HDR` : defaultLabel
593
+ * }
594
+ * ```
595
+ */
596
+ /** {en}
597
+ * @brief Localization mapping and custom formatter for HLS Level labels.
598
+ * @detail ref
599
+ * @example
600
+ * ``` javascript
601
+ * hlsLevelLabel: {
602
+ * map: {
603
+ * '720p': { textKey: 'HLS_LEVEL_HD', text: '720p' }
604
+ * },
605
+ * formatter: ({ defaultLabel, level }) =>
606
+ * level.videoRange === 'PQ' ? `${defaultLabel} HDR` : defaultLabel
607
+ * }
608
+ * ```
609
+ */
610
+ export interface IHlsLevelLabelOptions {
611
+ /** {zh} @brief 按标准标签(如 `720p`、`1080p`)配置展示文案。 */
612
+ /** {en} @brief Display-label mappings keyed by canonical labels such as `720p` and `1080p`. */
613
+ map?: Record<string, IHlsLevelLabelItem>;
614
+ /** {zh} @brief 同步格式化最终标签;返回空值或抛出异常时回退到 `defaultLabel`。 */
615
+ /** {en} @brief Synchronously formats the final label; empty returns or exceptions fall back to `defaultLabel`. */
616
+ formatter?: (context: IHlsLevelLabelContext) => string | null | undefined;
617
+ }
420
618
  /** {zh}
421
619
  * @brief 当前播放会话的 HLS Level 状态快照。
422
620
  * @detail ref
@@ -645,6 +843,71 @@ export interface IAutoBitrateOpts {
645
843
  */
646
844
  module?: unknown;
647
845
  }
846
+ interface AudioTrackOption {
847
+ /** {zh}
848
+ * @brief 音轨主要语言,BCP-47 格式(如 `zh`、`en`)。对应 `#EXT-X-MEDIA` 的 `LANGUAGE`。
849
+ */
850
+ /** {en}
851
+ * @brief Primary track language in BCP-47 format (e.g. `zh`, `en`). Maps to `#EXT-X-MEDIA` `LANGUAGE`.
852
+ */
853
+ lang?: string;
854
+ /** {zh}
855
+ * @brief 关联语言代码。对应 `#EXT-X-MEDIA` 的 `ASSOC-LANGUAGE`。
856
+ */
857
+ /** {en}
858
+ * @brief Associated language code. Maps to `#EXT-X-MEDIA` `ASSOC-LANGUAGE`.
859
+ */
860
+ assocLang?: string;
861
+ /** {zh}
862
+ * @brief 轨道特征描述字符串。对应 `#EXT-X-MEDIA` 的 `CHARACTERISTICS`(如 `public.accessibility.describes-video`)。
863
+ */
864
+ /** {en}
865
+ * @brief Track characteristics string. Maps to `#EXT-X-MEDIA` `CHARACTERISTICS`.
866
+ */
867
+ characteristics?: string;
868
+ /** {zh}
869
+ * @brief 声道数。对应 `#EXT-X-MEDIA` 的 `CHANNELS`(如 `"2"`)。
870
+ */
871
+ /** {en}
872
+ * @brief Number of audio channels. Maps to `#EXT-X-MEDIA` `CHANNELS` (e.g. `"2"`).
873
+ */
874
+ channels?: string;
875
+ /** {zh}
876
+ * @brief 音轨名称,用于展示或精确匹配(如 `Stereo`)。hls.js 路径下与 `lang` 组合可唯一定位轨道。
877
+ */
878
+ /** {en}
879
+ * @brief Track name for display or precise matching (e.g. `Stereo`). With `lang`, uniquely identifies a track on the hls.js path.
880
+ */
881
+ name?: string;
882
+ /** {zh}
883
+ * @brief 音频编解码器标识(如 `mp4a.40.2`)。
884
+ */
885
+ /** {en}
886
+ * @brief Audio codec identifier (e.g. `mp4a.40.2`).
887
+ */
888
+ audioCodec?: string;
889
+ /** {zh}
890
+ * @brief 音频组 ID。对应 `#EXT-X-MEDIA` 的 `GROUP-ID`。
891
+ */
892
+ /** {en}
893
+ * @brief Audio group ID. Maps to `#EXT-X-MEDIA` `GROUP-ID`.
894
+ */
895
+ groupId?: string;
896
+ /** {zh}
897
+ * @brief 是否为 manifest 中的默认音轨。
898
+ */
899
+ /** {en}
900
+ * @brief Whether this is the default track declared in the manifest.
901
+ */
902
+ default?: boolean;
903
+ /** {zh}
904
+ * @hidden
905
+ */
906
+ /** {en}
907
+ * @hidden
908
+ */
909
+ [key: string]: unknown;
910
+ }
648
911
  /** Video and audio codec names supported by the player. */
649
912
  export declare const CodecType: {
650
913
  readonly H264: "h264";
@@ -694,6 +957,9 @@ export declare const enum POSITIONS {
694
957
  /** Public event-name map shared by Lite and Full UMD constructors. */
695
958
  export interface LiteEvents {
696
959
  readonly READY: "ready";
960
+ readonly HLS_LEVEL_SWITCHING: "hls_level_switching";
961
+ readonly HLS_LEVEL_SWITCHED: "hls_level_switched";
962
+ readonly HLS_ABR_LIMIT_CHANGE: "hls_abr_limit_change";
697
963
  readonly [eventName: string]: string;
698
964
  }
699
965
  /** Legacy grouped event-name map. */
@@ -994,6 +1260,7 @@ export interface LiteStream<MediaUrl extends LiteMediaUrl = LiteMediaUrl> {
994
1260
  }
995
1261
  export interface LiteSubtitleConfig {
996
1262
  list?: LiteSubtitleItem[];
1263
+ label?: ISubtitleLabelOptions;
997
1264
  defaultSubtitleId?: string | number;
998
1265
  defaultSubtitleLanguage?: string | number;
999
1266
  mode?: "external" | "native";
@@ -1158,10 +1425,13 @@ export interface LitePlayerConfig<MediaUrl extends LiteMediaUrl = LiteMediaUrl,
1158
1425
  mobile?: LiteMobileConfig;
1159
1426
  start?: LiteStartConfig;
1160
1427
  enableHlsMSE?: boolean;
1428
+ enableMobileHlsPlugin?: boolean;
1429
+ enableHlsJs?: boolean;
1161
1430
  hlsLevelSwitchMode?: HlsLevelSwitchMode;
1162
1431
  useHlsPluginForSafari?: boolean;
1163
1432
  enableMp4MSE?: boolean;
1164
1433
  defaultDefinition?: string;
1434
+ audioPreference?: AudioTrackOption;
1165
1435
  plugins?: unknown[];
1166
1436
  presets?: unknown[];
1167
1437
  ignores?: string[];
@@ -1216,8 +1486,8 @@ export interface LiteDefinition {
1216
1486
  export interface LiteSubtitleItem {
1217
1487
  id?: string | number;
1218
1488
  language?: string | number;
1219
- label?: string | number;
1220
- text?: string;
1489
+ label?: ISubtitleLabelValue;
1490
+ text?: ISubtitleLabelValue;
1221
1491
  url?: string;
1222
1492
  isDefault?: boolean;
1223
1493
  source?: "config" | "hls";
@@ -1231,6 +1501,11 @@ export interface LitePluginConstructor<Instance extends LitePluginInstance = Lit
1231
1501
  readonly pluginName?: string;
1232
1502
  new (...args: unknown[]): Instance;
1233
1503
  }
1504
+ type LiteHlsEventPayloadMap = {
1505
+ hls_abr_limit_change: IHlsAbrLimitChangeEvent;
1506
+ hls_level_switching: IHlsLevelSwitchEvent;
1507
+ hls_level_switched: IHlsLevelSwitchEvent;
1508
+ };
1234
1509
  export interface LiteVePlayer {
1235
1510
  readonly preLoadData: {
1236
1511
  hit: number;
@@ -1257,6 +1532,7 @@ export interface LiteVePlayer {
1257
1532
  hideSubtitle(): void;
1258
1533
  next<MediaUrl extends LiteMediaUrl, StreamUrl extends LiteMediaUrl>(config: LitePlayerConfig<MediaUrl, StreamUrl>, isNewVideo?: boolean): Promise<void>;
1259
1534
  off(action: string, func: (...args: unknown[]) => void): void;
1535
+ on<EventName extends keyof LiteHlsEventPayloadMap>(action: EventName, func: (payload: LiteHlsEventPayloadMap[EventName]) => void): void;
1260
1536
  on(action: string, func: (...args: unknown[]) => void): void;
1261
1537
  once(action: string, func: (...args: unknown[]) => void): void;
1262
1538
  playNext<MediaUrl extends LiteMediaUrl, StreamUrl extends LiteMediaUrl>(config: LitePlayerConfig<MediaUrl, StreamUrl>, isNewVideo?: boolean): Promise<unknown>;