@byteplus/veplayer 1.19.0-rc.2 → 1.19.0-rc.3

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/index.d.ts CHANGED
@@ -546,6 +546,45 @@ export interface ISubtitleConfig {
546
546
  * @default -
547
547
  */
548
548
  list?: Array<ISubTitleItem>;
549
+ /** {zh}
550
+ * @brief 字幕选择项的多语言映射与自定义格式化配置。
551
+ * @notes 同时作用于业务配置字幕、Vid/PlayAuth 或短剧自动字幕,以及 Master M3U8 字幕。仅改变 VePlayer 字幕菜单文案,不改变字幕 ID、切换和渲染行为。iOS 系统字幕菜单不受此配置影响。
552
+ * @default -
553
+ * @example
554
+ * ``` javascript
555
+ * Subtitle: {
556
+ * label: {
557
+ * map: {
558
+ * language: {
559
+ * en: { textKey: 'SUBTITLE_EN', text: 'English' }
560
+ * }
561
+ * },
562
+ * formatter: ({ defaultLabel, item }) =>
563
+ * item.forced ? `${defaultLabel} · Forced` : defaultLabel
564
+ * }
565
+ * }
566
+ * ```
567
+ */
568
+ /** {en}
569
+ * @brief Localization mapping and custom formatter for subtitle option labels.
570
+ * @notes Applies to business-configured subtitles, Vid/PlayAuth or short-drama automatic subtitles, and Master M3U8 subtitles. It only changes labels in VePlayer subtitle menus; subtitle IDs, switching, and rendering are unchanged. The iOS system subtitle menu is not affected.
571
+ * @default -
572
+ * @example
573
+ * ``` javascript
574
+ * Subtitle: {
575
+ * label: {
576
+ * map: {
577
+ * language: {
578
+ * en: { textKey: 'SUBTITLE_EN', text: 'English' }
579
+ * }
580
+ * },
581
+ * formatter: ({ defaultLabel, item }) =>
582
+ * item.forced ? `${defaultLabel} · Forced` : defaultLabel
583
+ * }
584
+ * }
585
+ * ```
586
+ */
587
+ label?: ISubtitleLabelOptions;
549
588
  /** {zh}
550
589
  * @brief 是否默认打开字幕。
551
590
  * @default true
@@ -844,7 +883,7 @@ export interface ISubTitleItem {
844
883
  * @brief Subtitle display name.
845
884
  * @default -
846
885
  */
847
- text?: string;
886
+ text?: ISubtitleLabelValue;
848
887
  /** {zh}
849
888
  * @brief 字幕名称。兼容 xgplayer-subtitles 的 label 字段。
850
889
  * @default -
@@ -853,7 +892,7 @@ export interface ISubTitleItem {
853
892
  * @brief 字幕名称。兼容 xgplayer-subtitles 的 label 字段。
854
893
  * @default -
855
894
  */
856
- label?: string | number;
895
+ label?: ISubtitleLabelValue;
857
896
  /** {zh}
858
897
  * @brief 外挂字幕 URL 地址。
859
898
  * @default -
@@ -883,6 +922,118 @@ export interface ISubTitleItem {
883
922
  */
884
923
  list?: IListItem[];
885
924
  }
925
+ /** {zh}
926
+ * @brief 字幕项名称,可为静态文案或按播放器语言配置的文案表。
927
+ * @detail ref
928
+ */
929
+ /** {en}
930
+ * @brief Subtitle item name as static text or a text map keyed by player language.
931
+ * @detail ref
932
+ */
933
+ export declare type ISubtitleLabelValue = string | number | Record<string, string | number>;
934
+ /** {zh}
935
+ * @brief 字幕标签映射项。
936
+ * @detail ref
937
+ */
938
+ /** {en}
939
+ * @brief Mapping item used to customize a subtitle label.
940
+ * @detail ref
941
+ */
942
+ export interface ISubtitleLabelItem {
943
+ /** {zh} @brief 多语言 key 无法解析时使用的回退文案。 */
944
+ /** {en} @brief Fallback text used when the i18n key cannot be resolved. */
945
+ text?: string;
946
+ /** {zh} @brief 从播放器当前多语言词典中读取文案的 key。 */
947
+ /** {en} @brief Key resolved from the player's active i18n dictionary. */
948
+ textKey?: string;
949
+ }
950
+ /** {zh}
951
+ * @brief 字幕标签映射表。匹配优先级为 `id`、完整 `language`、基础 `language`、原始 `text`。
952
+ * @detail ref
953
+ */
954
+ /** {en}
955
+ * @brief Subtitle label maps. Match order is `id`, full `language`, base `language`, then source `text`.
956
+ * @detail ref
957
+ */
958
+ export interface ISubtitleLabelMap {
959
+ /** {zh} @brief 按稳定字幕 ID 映射;不建议用于会话内生成 ID 的 Master M3U8 字幕。 */
960
+ /** {en} @brief Maps stable subtitle IDs; not recommended for session-scoped Master M3U8 IDs. */
961
+ id?: Record<string, ISubtitleLabelItem>;
962
+ /** {zh} @brief 按字幕语言映射,忽略大小写并兼容 `_` 与 `-`。 */
963
+ /** {en} @brief Maps subtitle languages case-insensitively, treating `_` and `-` as equivalent. */
964
+ language?: Record<string, ISubtitleLabelItem>;
965
+ /** {zh} @brief 按字幕原始名称映射。 */
966
+ /** {en} @brief Maps the source subtitle name. */
967
+ text?: Record<string, ISubtitleLabelItem>;
968
+ }
969
+ /** {zh}
970
+ * @brief 传给字幕标签 formatter 的只读安全字幕快照,不包含 URL 或字幕内容。
971
+ * @detail ref
972
+ */
973
+ /** {en}
974
+ * @brief Read-only safe subtitle snapshot passed to the label formatter, excluding URLs and subtitle content.
975
+ * @detail ref
976
+ */
977
+ export interface ISubtitleLabelTrack {
978
+ source?: "config" | "hls";
979
+ id?: string | number;
980
+ language?: string | number;
981
+ isDefault?: boolean;
982
+ forced?: boolean;
983
+ characteristics?: string;
984
+ text?: string | number;
985
+ label?: string | number;
986
+ }
987
+ /** {zh}
988
+ * @brief 字幕标签格式化上下文。
989
+ * @detail ref
990
+ */
991
+ /** {en}
992
+ * @brief Context passed to the subtitle label formatter.
993
+ * @detail ref
994
+ */
995
+ export interface ISubtitleLabelContext {
996
+ /** {zh} @brief 当前字幕项的只读安全快照。 */
997
+ /** {en} @brief Read-only safe snapshot of the current subtitle item. */
998
+ item: Readonly<ISubtitleLabelTrack>;
999
+ /** {zh} @brief 当前字幕列表的只读安全快照。 */
1000
+ /** {en} @brief Read-only safe snapshots of the current subtitle list. */
1001
+ items: ReadonlyArray<Readonly<ISubtitleLabelTrack>>;
1002
+ /** {zh} @brief 当前字幕项在列表中的位置。 */
1003
+ /** {en} @brief Position of the current subtitle item in the list. */
1004
+ index: number;
1005
+ /** {zh} @brief 应用标签映射前的原始回退文案。 */
1006
+ /** {en} @brief Source fallback text before applying label mappings. */
1007
+ canonicalLabel: string;
1008
+ /** {zh} @brief 应用 `textKey` 或 `text` 后的文案。 */
1009
+ /** {en} @brief Label after applying `textKey` or `text`. */
1010
+ localizedLabel: string;
1011
+ /** {zh} @brief formatter 返回空值或抛出异常时使用的文案。 */
1012
+ /** {en} @brief Label used when the formatter returns an empty value or throws. */
1013
+ defaultLabel: string;
1014
+ /** {zh} @brief 播放器当前语言。 */
1015
+ /** {en} @brief Current player language. */
1016
+ lang: string;
1017
+ /** {zh} @brief 本地化后的文案是否在当前字幕列表中重复。 */
1018
+ /** {en} @brief Whether the localized label is duplicated in the current subtitle list. */
1019
+ duplicated: boolean;
1020
+ }
1021
+ /** {zh}
1022
+ * @brief 字幕标签多语言映射与自定义格式化配置。
1023
+ * @detail ref
1024
+ */
1025
+ /** {en}
1026
+ * @brief Localization mapping and custom formatter for subtitle labels.
1027
+ * @detail ref
1028
+ */
1029
+ export interface ISubtitleLabelOptions {
1030
+ /** {zh} @brief 按字幕 ID、语言或原始名称配置展示文案。 */
1031
+ /** {en} @brief Display-label mappings keyed by subtitle ID, language, or source name. */
1032
+ map?: ISubtitleLabelMap;
1033
+ /** {zh} @brief 同步格式化最终标签;返回空值、Promise 或抛出异常时回退到 `defaultLabel`。 */
1034
+ /** {en} @brief Synchronously formats the final label; empty values, Promises, or exceptions fall back to `defaultLabel`. */
1035
+ formatter?: (context: ISubtitleLabelContext) => string | null | undefined;
1036
+ }
886
1037
  export declare type IAutoSubtitleSourceItem = Record<string, any> | string;
887
1038
  export declare type IAutoSubtitleFormatterResult = string | number | boolean | null | undefined | {
888
1039
  label?: string | number;
@@ -3671,6 +3822,92 @@ export interface IHlsLevel {
3671
3822
  /** {en} @brief Level name declared by the manifest. */
3672
3823
  name?: string;
3673
3824
  }
3825
+ /** {zh}
3826
+ * @brief HLS Level 标签映射项。
3827
+ * @detail ref
3828
+ */
3829
+ /** {en}
3830
+ * @brief Mapping item used to customize an HLS Level label.
3831
+ * @detail ref
3832
+ */
3833
+ export interface IHlsLevelLabelItem {
3834
+ /** {zh} @brief 当多语言 key 无法解析时使用的回退文案。 */
3835
+ /** {en} @brief Fallback text used when the i18n key cannot be resolved. */
3836
+ text?: string;
3837
+ /** {zh} @brief 从播放器当前多语言词典中读取文案的 key。 */
3838
+ /** {en} @brief Key resolved from the player's active i18n dictionary. */
3839
+ textKey?: string;
3840
+ }
3841
+ /** {zh}
3842
+ * @brief HLS Level 标签格式化上下文。
3843
+ * @detail ref
3844
+ */
3845
+ /** {en}
3846
+ * @brief Context passed to the HLS Level label formatter.
3847
+ * @detail ref
3848
+ */
3849
+ export interface IHlsLevelLabelContext {
3850
+ /** {zh} @brief 当前 Level 的只读安全快照。 */
3851
+ /** {en} @brief Read-only safe snapshot of the current Level. */
3852
+ level: Readonly<IHlsLevel>;
3853
+ /** {zh} @brief 当前播放会话全部 Level 的只读安全快照。 */
3854
+ /** {en} @brief Read-only safe snapshots of all Levels in the current playback session. */
3855
+ levels: ReadonlyArray<Readonly<IHlsLevel>>;
3856
+ /** {zh} @brief 视频短边像素值;Manifest 未提供分辨率时为空。 */
3857
+ /** {en} @brief Video short edge in pixels, or undefined when dimensions are unavailable. */
3858
+ shortEdge?: number;
3859
+ /** {zh} @brief 未本地化、未消歧的标准标签。 */
3860
+ /** {en} @brief Canonical label before localization and disambiguation. */
3861
+ canonicalLabel: string;
3862
+ /** {zh} @brief 应用 `textKey` 或 `text` 后的基础标签。 */
3863
+ /** {en} @brief Base label after applying `textKey` or `text`. */
3864
+ localizedLabel: string;
3865
+ /** {zh} @brief 完成 SDK 默认重名消歧后的标签。 */
3866
+ /** {en} @brief Label after the SDK's default duplicate disambiguation. */
3867
+ defaultLabel: string;
3868
+ /** {zh} @brief 播放器当前语言。 */
3869
+ /** {en} @brief Current player language. */
3870
+ lang: string;
3871
+ /** {zh} @brief 当前标准标签是否在 Level 列表中重复。 */
3872
+ /** {en} @brief Whether the canonical label is duplicated in the Level list. */
3873
+ duplicated: boolean;
3874
+ }
3875
+ /** {zh}
3876
+ * @brief HLS Level 标签的多语言映射与自定义格式化配置。
3877
+ * @detail ref
3878
+ * @example
3879
+ * ``` javascript
3880
+ * hlsLevelLabel: {
3881
+ * map: {
3882
+ * '720p': { textKey: 'HLS_LEVEL_HD', text: '720p' }
3883
+ * },
3884
+ * formatter: ({ defaultLabel, level }) =>
3885
+ * level.videoRange === 'PQ' ? `${defaultLabel} HDR` : defaultLabel
3886
+ * }
3887
+ * ```
3888
+ */
3889
+ /** {en}
3890
+ * @brief Localization mapping and custom formatter for HLS Level labels.
3891
+ * @detail ref
3892
+ * @example
3893
+ * ``` javascript
3894
+ * hlsLevelLabel: {
3895
+ * map: {
3896
+ * '720p': { textKey: 'HLS_LEVEL_HD', text: '720p' }
3897
+ * },
3898
+ * formatter: ({ defaultLabel, level }) =>
3899
+ * level.videoRange === 'PQ' ? `${defaultLabel} HDR` : defaultLabel
3900
+ * }
3901
+ * ```
3902
+ */
3903
+ export interface IHlsLevelLabelOptions {
3904
+ /** {zh} @brief 按标准标签(如 `720p`、`1080p`)配置展示文案。 */
3905
+ /** {en} @brief Display-label mappings keyed by canonical labels such as `720p` and `1080p`. */
3906
+ map?: Record<string, IHlsLevelLabelItem>;
3907
+ /** {zh} @brief 同步格式化最终标签;返回空值或抛出异常时回退到 `defaultLabel`。 */
3908
+ /** {en} @brief Synchronously formats the final label; empty returns or exceptions fall back to `defaultLabel`. */
3909
+ formatter?: (context: IHlsLevelLabelContext) => string | null | undefined;
3910
+ }
3674
3911
  /** {zh}
3675
3912
  * @brief 当前播放会话的 HLS Level 状态快照。
3676
3913
  * @detail ref
@@ -5136,6 +5373,51 @@ export interface IPlayerConfig extends IPlayerOptions {
5136
5373
  * ```
5137
5374
  */
5138
5375
  hlsLevelSwitchMode?: HlsLevelSwitchMode;
5376
+ /** {zh}
5377
+ * @brief Master M3U8 的 HLS Level 标签多语言映射与自定义格式化配置。
5378
+ * @notes 仅影响内置清晰度插件的展示文案,不改变 Level 索引、切档行为或 ABR 决策。映射 key 为视频短边生成的标准标签,例如 `720p`、`1080p`。
5379
+ * @default -
5380
+ * @example
5381
+ * ``` javascript
5382
+ * const playerSdkIns = new VePlayer({
5383
+ * lang: 'zh',
5384
+ * languages: {
5385
+ * zh: { HLS_LEVEL_HD: '高清' },
5386
+ * en: { HLS_LEVEL_HD: 'HD' }
5387
+ * },
5388
+ * hlsLevelLabel: {
5389
+ * map: {
5390
+ * '720p': { textKey: 'HLS_LEVEL_HD', text: '720p' }
5391
+ * },
5392
+ * formatter: ({ defaultLabel, level }) =>
5393
+ * level.videoRange === 'PQ' ? `${defaultLabel} HDR` : defaultLabel
5394
+ * }
5395
+ * });
5396
+ * ```
5397
+ */
5398
+ /** {en}
5399
+ * @brief Localization mapping and custom formatter for Master M3U8 HLS Level labels.
5400
+ * @notes Only changes labels rendered by the built-in quality plugin. It does not change Level indices, switching behavior, or ABR decisions. Mapping keys are canonical short-edge labels such as `720p` and `1080p`.
5401
+ * @default -
5402
+ * @example
5403
+ * ``` javascript
5404
+ * const playerSdkIns = new VePlayer({
5405
+ * lang: 'en',
5406
+ * languages: {
5407
+ * zh: { HLS_LEVEL_HD: '高清' },
5408
+ * en: { HLS_LEVEL_HD: 'HD' }
5409
+ * },
5410
+ * hlsLevelLabel: {
5411
+ * map: {
5412
+ * '720p': { textKey: 'HLS_LEVEL_HD', text: '720p' }
5413
+ * },
5414
+ * formatter: ({ defaultLabel, level }) =>
5415
+ * level.videoRange === 'PQ' ? `${defaultLabel} HDR` : defaultLabel
5416
+ * }
5417
+ * });
5418
+ * ```
5419
+ */
5420
+ hlsLevelLabel?: IHlsLevelLabelOptions;
5139
5421
  /** {zh}
5140
5422
  * @brief 是否启用 {@link https://hlsjs.video-dev.org/ hls.js} 插件播放HLS视频,默认为true,设置为false后,PC端播放HLS使用自研hls插件播放HLS视频
5141
5423
  * @default true
@@ -7086,7 +7368,7 @@ export interface ISubTitleItem {
7086
7368
  * @brief Subtitle display name.
7087
7369
  * @default -
7088
7370
  */
7089
- text?: string;
7371
+ text?: ISubtitleLabelValue;
7090
7372
  /** {zh}
7091
7373
  * @brief 字幕名称。兼容 xgplayer-subtitles 的 label 字段。
7092
7374
  * @default -
@@ -7095,7 +7377,7 @@ export interface ISubTitleItem {
7095
7377
  * @brief 字幕名称。兼容 xgplayer-subtitles 的 label 字段。
7096
7378
  * @default -
7097
7379
  */
7098
- label?: string | number;
7380
+ label?: ISubtitleLabelValue;
7099
7381
  /** {zh}
7100
7382
  * @brief 外挂字幕 URL 地址。
7101
7383
  * @default -
@@ -7125,6 +7407,15 @@ export interface ISubTitleItem {
7125
7407
  */
7126
7408
  list?: IListItem[];
7127
7409
  }
7410
+ /** {zh}
7411
+ * @brief 字幕项名称,可为静态文案或按播放器语言配置的文案表。
7412
+ * @detail ref
7413
+ */
7414
+ /** {en}
7415
+ * @brief Subtitle item name as static text or a text map keyed by player language.
7416
+ * @detail ref
7417
+ */
7418
+ export type ISubtitleLabelValue = string | number | Record<string, string | number>;
7128
7419
  /** {zh}
7129
7420
  * @brief 字幕内容项。
7130
7421
  * @list Options
@@ -9954,6 +10245,7 @@ export declare class Subtitle extends Plugin {
9954
10245
  "zh-hk": string;
9955
10246
  };
9956
10247
  };
10248
+ updateLang(lang: string): void;
9957
10249
  creatOptionList(): void;
9958
10250
  getList(): any;
9959
10251
  renderOptionList(): void;