@byteplus/veplayer 1.18.0 → 1.19.0-rc.1

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
@@ -577,6 +577,19 @@ export interface ISubtitleConfig {
577
577
  * @default external
578
578
  */
579
579
  mode?: "external" | "native";
580
+ /** {zh}
581
+ * @brief 原生字幕渲染方式。仅当 `mode` 为 `native` 且使用 iOS 原生 HLS 时生效:
582
+ * - `"system"`:由系统渲染字幕。
583
+ * - `"dom"`:内联播放时由 VePlayer 使用 DOM 渲染;原生全屏、画中画或远程播放时自动回退到系统渲染。
584
+ * @default system
585
+ */
586
+ /** {en}
587
+ * @brief Native subtitle rendering mode. It only applies to iOS native HLS when `mode` is `native`:
588
+ * - `"system"`: render subtitles with the system UI.
589
+ * - `"dom"`: render subtitles in the VePlayer DOM during inline playback and fall back to system rendering in native fullscreen, picture-in-picture, or remote playback.
590
+ * @default system
591
+ */
592
+ nativeRenderMode?: "system" | "dom";
580
593
  /**
581
594
  * @brief 字幕更新模式,默认vod
582
595
  * @default vod
@@ -769,6 +782,15 @@ export interface ISubtitleStyle {
769
782
  * @kind property
770
783
  */
771
784
  export interface ISubTitleItem {
785
+ /** {zh}
786
+ * @brief 字幕来源。业务配置字幕为 `config`,Master M3U8 或原生 HLS 字幕为 `hls`。
787
+ * @default config
788
+ */
789
+ /** {en}
790
+ * @brief Subtitle source. Business-configured subtitles use `config`; Master M3U8 or native HLS subtitles use `hls`.
791
+ * @default config
792
+ */
793
+ source?: "config" | "hls";
772
794
  /** {zh}
773
795
  * @brief 字幕语言。
774
796
  * @default -
@@ -796,6 +818,24 @@ export interface ISubTitleItem {
796
818
  * @default false
797
819
  */
798
820
  isDefault?: boolean;
821
+ /** {zh}
822
+ * @brief 是否为强制字幕轨。
823
+ * @default false
824
+ */
825
+ /** {en}
826
+ * @brief Whether the subtitle track is forced.
827
+ * @default false
828
+ */
829
+ forced?: boolean;
830
+ /** {zh}
831
+ * @brief HLS 字幕轨的特征标识,例如无障碍字幕特征;未声明时为空。
832
+ * @default -
833
+ */
834
+ /** {en}
835
+ * @brief HLS subtitle-track characteristics, such as accessibility traits; absent when not declared.
836
+ * @default -
837
+ */
838
+ characteristics?: string;
799
839
  /** {zh}
800
840
  * @brief 字幕名称。
801
841
  * @default -
@@ -3415,6 +3455,379 @@ export interface IVideoInfo {
3415
3455
  Data: IGetPlayInfoRes;
3416
3456
  };
3417
3457
  }
3458
+ /** {zh}
3459
+ * @brief VePlayer 实际使用的 HLS 播放内核。
3460
+ * @detail ref
3461
+ */
3462
+ /** {en}
3463
+ * @brief The HLS playback engine actually used by VePlayer.
3464
+ * @detail ref
3465
+ */
3466
+ export declare type HlsPlaybackEngine = "hlsjs" | "veplayer-hls" | "native" | "none";
3467
+ /** {zh}
3468
+ * @brief HLS 自动码率决策引擎配置值。
3469
+ * @detail ref
3470
+ */
3471
+ /** {en}
3472
+ * @brief Configurable HLS adaptive-bitrate decision engine.
3473
+ * @detail ref
3474
+ */
3475
+ export declare type HlsAbrEngine = "hlsjs" | "veplayer";
3476
+ /** {zh}
3477
+ * @brief 当前播放会话最终解析出的自动码率决策引擎。
3478
+ * @detail ref
3479
+ */
3480
+ /** {en}
3481
+ * @brief Adaptive-bitrate decision engine resolved for the current playback session.
3482
+ * @detail ref
3483
+ */
3484
+ export declare type ResolvedAbrEngine = HlsAbrEngine | "native" | "none";
3485
+ /** {zh}
3486
+ * @brief HLS 自动码率控制模式。
3487
+ * @detail ref
3488
+ */
3489
+ /** {en}
3490
+ * @brief HLS adaptive-bitrate control mode.
3491
+ * @detail ref
3492
+ */
3493
+ export declare type HlsAbrMode = "auto" | "manual";
3494
+ /** {zh}
3495
+ * @brief 当前播放会话无法使用 HLS ABR 的原因。
3496
+ * @detail ref
3497
+ */
3498
+ /** {en}
3499
+ * @brief Reason why HLS ABR is unavailable for the current playback session.
3500
+ * @detail ref
3501
+ */
3502
+ export declare type HlsAbrUnavailableReason = "NOT_HLS" | "NOT_HLSJS_ENGINE" | "MANIFEST_NOT_READY" | "MULTI_LEVEL_MASTER_REQUIRED" | "DEFINITION_LIST_REQUIRED" | "ABR_MODULE_UNAVAILABLE" | "ABR_RUNTIME_UNAVAILABLE" | "LICENSE_UNAVAILABLE" | "NO_ABR_VARIANTS";
3503
+ /** {zh}
3504
+ * @brief 当前 HLS 播放会话支持的 ABR 能力。
3505
+ * @detail ref
3506
+ */
3507
+ /** {en}
3508
+ * @brief ABR capabilities supported by the current HLS playback session.
3509
+ * @detail ref
3510
+ */
3511
+ export interface IHlsAbrCapabilities {
3512
+ /** {zh} @brief 是否可读取 HLS Level 列表。 */
3513
+ /** {en} @brief Whether the HLS Level list is available. */
3514
+ levelList: boolean;
3515
+ /** {zh} @brief 是否支持手动切换 HLS Level。 */
3516
+ /** {en} @brief Whether manual HLS Level switching is supported. */
3517
+ manualLevelSwitch: boolean;
3518
+ /** {zh} @brief 是否支持恢复当前 ABR 引擎的自动模式。 */
3519
+ /** {en} @brief Whether automatic mode can be restored for the resolved ABR engine. */
3520
+ restoreAuto: boolean;
3521
+ /** {zh} @brief 是否支持按 Level 设置自动码率上限。 */
3522
+ /** {en} @brief Whether an automatic bitrate cap can be set by Level. */
3523
+ levelCap: boolean;
3524
+ /** {zh} @brief 是否支持按码率设置自动码率上限。 */
3525
+ /** {en} @brief Whether an automatic bitrate cap can be set by bitrate. */
3526
+ bitrateCap: boolean;
3527
+ /** {zh} @brief 是否支持按 VePlayer 清晰度设置自动码率上限。 */
3528
+ /** {en} @brief Whether an automatic bitrate cap can be set by VePlayer definition. */
3529
+ definitionCap: boolean;
3530
+ }
3531
+ /** {zh}
3532
+ * @brief 当前播放会话的 HLS ABR 状态快照。
3533
+ * @detail ref
3534
+ */
3535
+ /** {en}
3536
+ * @brief HLS ABR state snapshot for the current playback session.
3537
+ * @detail ref
3538
+ */
3539
+ export interface IHlsAbrState {
3540
+ /** {zh} @brief 播放会话 ID,用于识别过期状态和事件。 */
3541
+ /** {en} @brief Playback session ID used to reject stale state and events. */
3542
+ playbackSessionId: string;
3543
+ /** {zh} @brief VePlayer 实际使用的 HLS 播放内核。 */
3544
+ /** {en} @brief HLS playback engine actually used by VePlayer. */
3545
+ playbackEngine: HlsPlaybackEngine;
3546
+ /** {zh} @brief 业务显式配置的 ABR 引擎;未配置时为 `null`。 */
3547
+ /** {en} @brief Explicitly configured ABR engine, or `null` when omitted. */
3548
+ configuredEngine: HlsAbrEngine | null;
3549
+ /** {zh} @brief 当前播放会话最终解析出的 ABR 决策引擎。 */
3550
+ /** {en} @brief ABR decision engine resolved for the current playback session. */
3551
+ engine: ResolvedAbrEngine;
3552
+ /** {zh} @brief 当前清晰度决策使用的数据源。 */
3553
+ /** {en} @brief Data source used for the current rendition decision. */
3554
+ decisionSource: "hls-levels" | "definition-list" | "native" | "none";
3555
+ /** {zh} @brief 当前播放会话是否具备所选 ABR 引擎所需条件。 */
3556
+ /** {en} @brief Whether the selected ABR engine is available in the current session. */
3557
+ available: boolean;
3558
+ /** {zh} @brief 当前 ABR 决策引擎是否正在自动选档。 */
3559
+ /** {en} @brief Whether the resolved ABR engine is actively selecting renditions. */
3560
+ active: boolean;
3561
+ /** {zh} @brief 当前为自动模式还是手动模式。 */
3562
+ /** {en} @brief Whether the current mode is automatic or manual. */
3563
+ mode: HlsAbrMode;
3564
+ /** {zh} @brief hls.js 当前实际播放的 Level 索引。 */
3565
+ /** {en} @brief Current hls.js Level index being rendered. */
3566
+ currentLevel?: number;
3567
+ /** {zh} @brief VePlayer ABR 当前实际播放的清晰度。 */
3568
+ /** {en} @brief Current definition rendered by VePlayer ABR. */
3569
+ currentDefinition?: string;
3570
+ /** {zh} @brief ABR 不可用时的稳定原因码。 */
3571
+ /** {en} @brief Stable reason code when ABR is unavailable. */
3572
+ reason?: HlsAbrUnavailableReason;
3573
+ /** {zh} @brief 当前播放会话支持的 ABR 控制能力。 */
3574
+ /** {en} @brief ABR control capabilities supported by the current session. */
3575
+ capabilities: IHlsAbrCapabilities;
3576
+ }
3577
+ /** {zh}
3578
+ * @brief HLS ABR 上限;`null` 表示清除上限。
3579
+ * @detail ref
3580
+ */
3581
+ /** {en}
3582
+ * @brief HLS ABR limit; `null` clears the active limit.
3583
+ * @detail ref
3584
+ */
3585
+ export declare type IHlsAbrLimit = {
3586
+ type: "level";
3587
+ maxLevel: number;
3588
+ } | {
3589
+ type: "bitrate";
3590
+ maxBitrate: number;
3591
+ } | {
3592
+ type: "definition";
3593
+ maxDefinition: string;
3594
+ } | null;
3595
+ /** {zh}
3596
+ * @brief `HLS_ABR_ENGINE_RESOLVED` 事件数据。
3597
+ * @detail ref
3598
+ */
3599
+ /** {en}
3600
+ * @brief Payload of the `HLS_ABR_ENGINE_RESOLVED` event.
3601
+ * @detail ref
3602
+ */
3603
+ export interface IHlsAbrEngineResolvedEvent extends IHlsAbrState {
3604
+ }
3605
+ /** {zh}
3606
+ * @brief `HLS_ABR_STATE_CHANGE` 事件数据。
3607
+ * @detail ref
3608
+ */
3609
+ /** {en}
3610
+ * @brief Payload of the `HLS_ABR_STATE_CHANGE` event.
3611
+ * @detail ref
3612
+ */
3613
+ export interface IHlsAbrStateChangeEvent extends IHlsAbrState {
3614
+ }
3615
+ /** {zh}
3616
+ * @brief `HLS_ABR_LIMIT_CHANGE` 事件数据。
3617
+ * @detail ref
3618
+ */
3619
+ /** {en}
3620
+ * @brief Payload of the `HLS_ABR_LIMIT_CHANGE` event.
3621
+ * @detail ref
3622
+ */
3623
+ export interface IHlsAbrLimitChangeEvent {
3624
+ /** {zh} @brief 事件所属的播放会话 ID。 */
3625
+ /** {en} @brief Playback session ID that owns the event. */
3626
+ playbackSessionId: string;
3627
+ /** {zh} @brief 当前播放会话最终解析出的 ABR 决策引擎。 */
3628
+ /** {en} @brief ABR decision engine resolved for the current playback session. */
3629
+ engine: ResolvedAbrEngine;
3630
+ /** {zh} @brief 已生效的 ABR 上限;`null` 表示上限已清除。 */
3631
+ /** {en} @brief Applied ABR limit, or `null` when the limit has been cleared. */
3632
+ limit: IHlsAbrLimit;
3633
+ }
3634
+ /** {zh}
3635
+ * @brief Master M3U8 中一个标准化的 HLS Level;`index` 仅在当前播放会话内有效。
3636
+ * @detail ref
3637
+ */
3638
+ /** {en}
3639
+ * @brief A normalized HLS Level from a Master M3U8; `index` is valid only in the current playback session.
3640
+ * @detail ref
3641
+ */
3642
+ export interface IHlsLevel {
3643
+ /** {zh} @brief 当前播放会话内的 Level 索引。 */
3644
+ /** {en} @brief Level index within the current playback session. */
3645
+ index: number;
3646
+ /** {zh} @brief 峰值码率,单位为 bit/s。 */
3647
+ /** {en} @brief Peak bitrate in bits per second. */
3648
+ bitrate: number;
3649
+ /** {zh} @brief 平均码率,单位为 bit/s。 */
3650
+ /** {en} @brief Average bitrate in bits per second. */
3651
+ averageBitrate?: number;
3652
+ /** {zh} @brief 视频宽度,单位为像素。 */
3653
+ /** {en} @brief Video width in pixels. */
3654
+ width?: number;
3655
+ /** {zh} @brief 视频高度,单位为像素。 */
3656
+ /** {en} @brief Video height in pixels. */
3657
+ height?: number;
3658
+ /** {zh} @brief 视频帧率。 */
3659
+ /** {en} @brief Video frame rate. */
3660
+ frameRate?: number;
3661
+ /** {zh} @brief 视频编码标识。 */
3662
+ /** {en} @brief Video codec identifier. */
3663
+ videoCodec?: string;
3664
+ /** {zh} @brief 音频编码标识。 */
3665
+ /** {en} @brief Audio codec identifier. */
3666
+ audioCodec?: string;
3667
+ /** {zh} @brief 视频动态范围标识。 */
3668
+ /** {en} @brief Video dynamic-range identifier. */
3669
+ videoRange?: string;
3670
+ /** {zh} @brief Manifest 声明的 Level 名称。 */
3671
+ /** {en} @brief Level name declared by the manifest. */
3672
+ name?: string;
3673
+ }
3674
+ /** {zh}
3675
+ * @brief 当前播放会话的 HLS Level 状态快照。
3676
+ * @detail ref
3677
+ */
3678
+ /** {en}
3679
+ * @brief HLS Level state snapshot for the current playback session.
3680
+ * @detail ref
3681
+ */
3682
+ export interface IHlsLevelState {
3683
+ /** {zh} @brief 播放会话 ID,用于识别过期状态和事件。 */
3684
+ /** {en} @brief Playback session ID used to reject stale state and events. */
3685
+ playbackSessionId: string;
3686
+ /** {zh} @brief Level 列表是否已就绪。 */
3687
+ /** {en} @brief Whether the Level list is ready. */
3688
+ ready: boolean;
3689
+ /** {zh} @brief 当前播放会话内的标准化 Level 列表。 */
3690
+ /** {en} @brief Normalized Level list for the current playback session. */
3691
+ levels: IHlsLevel[];
3692
+ /** {zh} @brief 当前实际播放的 Level 索引,未知时为 `-1`。 */
3693
+ /** {en} @brief Currently rendered Level index, or `-1` when unknown. */
3694
+ currentLevel: number;
3695
+ /** {zh} @brief 当前加载的 Level 索引,未知时为 `-1`。 */
3696
+ /** {en} @brief Currently loaded Level index, or `-1` when unknown. */
3697
+ loadLevel: number;
3698
+ /** {zh} @brief 下一个分片使用的 Level 索引,未知时为 `-1`。 */
3699
+ /** {en} @brief Level index for the next fragment, or `-1` when unknown. */
3700
+ nextLevel: number;
3701
+ /** {zh} @brief 手动 Level 索引;自动模式下为 `-1`。 */
3702
+ /** {en} @brief Manual Level index; `-1` in automatic mode. */
3703
+ manualLevel: number;
3704
+ /** {zh} @brief hls.js 是否处于自动选档模式。 */
3705
+ /** {en} @brief Whether hls.js automatic Level selection is enabled. */
3706
+ autoLevelEnabled: boolean;
3707
+ /** {zh} @brief hls.js 自动选档的 Level 上限;未设置时为 `-1`。 */
3708
+ /** {en} @brief hls.js automatic Level cap; `-1` when unset. */
3709
+ autoLevelCapping: number;
3710
+ }
3711
+ /** {zh}
3712
+ * @brief HLS Level 手动切换模式。
3713
+ * @detail ref
3714
+ */
3715
+ /** {en}
3716
+ * @brief Manual HLS Level switching mode.
3717
+ * @detail ref
3718
+ */
3719
+ export declare type HlsLevelSwitchMode = "immediate" | "next-fragment" | "smooth";
3720
+ /** {zh}
3721
+ * @brief 手动切换 HLS Level 的选项。
3722
+ * @detail ref
3723
+ */
3724
+ /** {en}
3725
+ * @brief Options for manually switching an HLS Level.
3726
+ * @detail ref
3727
+ */
3728
+ export interface IHlsLevelSwitchOptions {
3729
+ /** {zh} @brief 切换模式,默认为 `next-fragment`。 */
3730
+ /** {en} @brief Switching mode. Defaults to `next-fragment`. */
3731
+ mode?: HlsLevelSwitchMode;
3732
+ /** {zh} @brief 可选的播放会话 ID;不匹配时拒绝本次切换。 */
3733
+ /** {en} @brief Optional playback session ID; a mismatch rejects the switch. */
3734
+ playbackSessionId?: string;
3735
+ }
3736
+ /** {zh}
3737
+ * @brief HLS Level 切换事件数据。
3738
+ * @detail ref
3739
+ */
3740
+ /** {en}
3741
+ * @brief HLS Level switching event payload.
3742
+ * @detail ref
3743
+ */
3744
+ export interface IHlsLevelSwitchEvent {
3745
+ /** {zh} @brief 事件所属的播放会话 ID。 */
3746
+ /** {en} @brief Playback session ID that owns the event. */
3747
+ playbackSessionId: string;
3748
+ /** {zh} @brief 切换前的 Level 索引。 */
3749
+ /** {en} @brief Level index before switching. */
3750
+ from: number;
3751
+ /** {zh} @brief 目标或已切换到的 Level 索引。 */
3752
+ /** {en} @brief Target or switched-to Level index. */
3753
+ to: number;
3754
+ /** {zh} @brief 本次切换由手动操作还是 ABR 触发。 */
3755
+ /** {en} @brief Whether the switch was triggered manually or by ABR. */
3756
+ reason: "manual" | "abr";
3757
+ /** {zh} @brief 当前播放会话的 ABR 决策引擎。 */
3758
+ /** {en} @brief ABR decision engine for the current playback session. */
3759
+ abrEngine: ResolvedAbrEngine;
3760
+ /** {zh} @brief 目标或已生效的安全 Level 快照。 */
3761
+ /** {en} @brief Safe snapshot of the target or active Level. */
3762
+ level?: IHlsLevel;
3763
+ }
3764
+ /** {zh}
3765
+ * @brief `HLS_SUBTITLE_TRACKS_UPDATED` 事件数据。
3766
+ * @detail ref
3767
+ */
3768
+ /** {en}
3769
+ * @brief Payload of the `HLS_SUBTITLE_TRACKS_UPDATED` event.
3770
+ * @detail ref
3771
+ */
3772
+ export interface IHlsSubtitleTracksUpdatedEvent {
3773
+ /** {zh} @brief 事件所属的播放会话 ID。 */
3774
+ /** {en} @brief Playback session ID that owns the event. */
3775
+ playbackSessionId: string;
3776
+ /** {zh} @brief 当前实际使用的 HLS 播放内核。 */
3777
+ /** {en} @brief HLS playback engine actually used by the session. */
3778
+ playbackEngine: HlsPlaybackEngine;
3779
+ /** {zh} @brief 不含播放地址和底层轨道索引的安全字幕列表。 */
3780
+ /** {en} @brief Safe subtitle list without media URLs or internal track indexes. */
3781
+ tracks: ReadonlyArray<ISubTitleItem>;
3782
+ }
3783
+ /** {zh}
3784
+ * @brief HLS 字幕轨切换事件数据。
3785
+ * @detail ref
3786
+ */
3787
+ /** {en}
3788
+ * @brief HLS subtitle-track switching event payload.
3789
+ * @detail ref
3790
+ */
3791
+ export interface IHlsSubtitleTrackSwitchEvent {
3792
+ /** {zh} @brief 事件所属的播放会话 ID。 */
3793
+ /** {en} @brief Playback session ID that owns the event. */
3794
+ playbackSessionId: string;
3795
+ /** {zh} @brief 当前实际使用的 HLS 播放内核。 */
3796
+ /** {en} @brief HLS playback engine actually used by the session. */
3797
+ playbackEngine: HlsPlaybackEngine;
3798
+ /** {zh} @brief 切换前的安全字幕 ID;关闭状态为 `null`。 */
3799
+ /** {en} @brief Safe subtitle ID before switching, or `null` when disabled. */
3800
+ from: string | number | null;
3801
+ /** {zh} @brief 目标或已生效的安全字幕 ID;关闭状态为 `null`。 */
3802
+ /** {en} @brief Target or active safe subtitle ID, or `null` when disabled. */
3803
+ to: string | number | null;
3804
+ /** {zh} @brief 目标或已生效的安全字幕快照。 */
3805
+ /** {en} @brief Safe snapshot of the target or active subtitle track. */
3806
+ track?: ISubTitleItem;
3807
+ }
3808
+ /** {zh}
3809
+ * @brief HLS 控制 API 的标准错误码。
3810
+ * @detail ref
3811
+ */
3812
+ /** {en}
3813
+ * @brief Standard error codes for HLS control APIs.
3814
+ * @detail ref
3815
+ */
3816
+ export declare type HlsControlErrorCode = "HLS_MANIFEST_NOT_READY" | "HLS_ENGINE_UNSUPPORTED" | "HLS_LEVEL_OUT_OF_RANGE" | "HLS_PLAYBACK_SESSION_EXPIRED" | "HLS_ABR_UNAVAILABLE" | "HLS_ABR_LIMIT_UNSUPPORTED" | "HLS_SUBTITLE_TRACK_NOT_FOUND" | "HLS_SUBTITLE_TRACK_AMBIGUOUS" | "HLS_SUBTITLE_SWITCH_FAILED" | "HLS_SUBTITLE_SWITCH_TIMEOUT";
3817
+ /** {zh}
3818
+ * @brief HLS Level、ABR 或字幕控制失败时抛出的标准错误。
3819
+ * @detail Api
3820
+ */
3821
+ /** {en}
3822
+ * @brief Standard error thrown when HLS Level, ABR, or subtitle control fails.
3823
+ * @detail Api
3824
+ */
3825
+ export declare class HlsControlError extends Error {
3826
+ /** {zh} @brief 稳定的 HLS 控制错误码。 */
3827
+ /** {en} @brief Stable HLS control error code. */
3828
+ readonly code: HlsControlErrorCode;
3829
+ constructor(code: HlsControlErrorCode, message: string);
3830
+ }
3418
3831
  export declare type TAPIRegionConfig = {
3419
3832
  __PLAY_DOMAIN__: string;
3420
3833
  __BACKUP_PLAY_DOMAIN__?: string;
@@ -4686,6 +5099,7 @@ export interface IPlayerConfig extends IPlayerOptions {
4686
5099
  * - **Android**:直接启用 hls.js 播放。
4687
5100
  * - **iOS**:仅在设备支持 `ManagedMediaSource`(iOS 17.1+,即 `VePlayer.isMMSSupported()` 为 `true`)时启用;
4688
5101
  * 不满足时自动回退至原生 HLS 播放。
5102
+ * - **`isMobile` 模拟模式**:当前浏览器支持 MSE 或 MMS 时启用 hls.js。
4689
5103
  * 开启后可在移动端解锁多音轨切换、`setAudioOption` 偏好持久化等 hls.js 特有能力。
4690
5104
  * @default false
4691
5105
  */
@@ -4694,10 +5108,34 @@ export interface IPlayerConfig extends IPlayerOptions {
4694
5108
  * - **Android**: always enables hls.js.
4695
5109
  * - **iOS**: enables hls.js only when `ManagedMediaSource` is supported (iOS 17.1+,
4696
5110
  * i.e. `VePlayer.isMMSSupported()` returns `true`); falls back to native HLS otherwise.
5111
+ * - **`isMobile` simulation**: enables hls.js when the current browser supports MSE or MMS.
4697
5112
  * Unlocks hls.js-specific features such as multi-audio-track switching on mobile.
4698
5113
  * @default false
4699
5114
  */
4700
5115
  enableMobileHlsPlugin?: boolean;
5116
+ /** {zh}
5117
+ * @brief 清晰度插件手动切换 HLS Level 时使用的切换模式。
5118
+ * @notes 仅在 hls.js/MSE/MMS 模式下生效;默认值为 `next-fragment`。直接调用 `setHlsLevel()` 时,以方法参数中的 `mode` 为准。
5119
+ * @default next-fragment
5120
+ * @example
5121
+ * ``` javascript
5122
+ * const playerSdkIns = new VePlayer({
5123
+ * hlsLevelSwitchMode: 'smooth'
5124
+ * });
5125
+ * ```
5126
+ */
5127
+ /** {en}
5128
+ * @brief Switching mode used when the quality plugin manually selects an HLS Level.
5129
+ * @notes Effective only in hls.js/MSE/MMS mode. Defaults to `next-fragment`. A `mode` passed directly to `setHlsLevel()` takes precedence for that call.
5130
+ * @default next-fragment
5131
+ * @example
5132
+ * ``` javascript
5133
+ * const playerSdkIns = new VePlayer({
5134
+ * hlsLevelSwitchMode: 'smooth'
5135
+ * });
5136
+ * ```
5137
+ */
5138
+ hlsLevelSwitchMode?: HlsLevelSwitchMode;
4701
5139
  /** {zh}
4702
5140
  * @brief 是否启用 {@link https://hlsjs.video-dev.org/ hls.js} 插件播放HLS视频,默认为true,设置为false后,PC端播放HLS使用自研hls插件播放HLS视频
4703
5141
  * @default true
@@ -6575,71 +7013,294 @@ declare abstract class AbstractBaseAdapter {
6575
7013
  abstract getPlugins(umdLoader: UMDLoader): Promise<XGPlugin[]>;
6576
7014
  abstract setPluginConfigInVid(videoInfo: IVideoInfo, context: AuthToken): void;
6577
7015
  }
6578
- declare class PlayerData {
6579
- id?: string;
6580
- root?: HTMLElement;
6581
- configs: IPlayerConfig;
6582
- type: string;
6583
- isLive: boolean;
6584
- options: any;
6585
- isMobile: boolean;
6586
- playList: Stream[];
6587
- plugins: any[];
6588
- openSoftDecoding: boolean;
6589
- defaultConfig: IDefaultConfig | undefined;
6590
- isHitDefault: boolean;
6591
- codec?: ICodecType;
6592
- enableH265Degrade: boolean;
6593
- languageData: {
6594
- extraLangList: IXGI18nText[];
6595
- extendLangList: IXGI18nText[];
6596
- };
6597
- current: Current;
6598
- onMediaExpired: () => Promise<SourceConfig>;
6599
- onTokenExpired: () => Promise<IPlayAuthTokenConfig>;
6600
- unionId?: string;
6601
- unionInfo?: string;
6602
- isMusic?: boolean;
6603
- sdkPlugins: any[];
6604
- useHlsPluginForSafari: boolean;
6605
- enableHlsJs: boolean;
6606
- enableMenu: boolean;
6607
- region: TRegionType;
6608
- userRegion: TRegionType;
6609
- playDomainDegrade: boolean;
6610
- strategiesPlugins: any[];
6611
- strategiesPluginConfigs: any;
6612
- /**
6613
- * @default playList第一项
6614
- */
6615
- defaultDefinition: string;
6616
- urlCheckData: {
6617
- enableUrlExpireCheck: boolean;
6618
- urlExpireTimestamp: number;
6619
- urlExpireDiff: number;
6620
- urlCheckExpireInterval: number;
6621
- };
6622
- private isAutoBitrateEnable;
6623
- adapter: AbstractBaseAdapter;
6624
- /**
6625
- * @breif 是否vid模式的加密播放
7016
+ /** {zh}
7017
+ * @list Options
7018
+ * @brief 字幕项。
7019
+ * @kind property
7020
+ */
7021
+ /** {en}
7022
+ * @list Options
7023
+ * @brief Subtitle item.
7024
+ * @kind property
7025
+ */
7026
+ export interface ISubTitleItem {
7027
+ /** {zh}
7028
+ * @brief 字幕来源。业务配置字幕为 `config`,Master M3U8 或原生 HLS 字幕为 `hls`。
7029
+ * @default config
6626
7030
  */
6627
- isVidEncrypt: boolean;
6628
- dashOpts: {
6629
- Data: IGetPlayInfoRes;
6630
- };
6631
- /**
6632
- * @brief 播放器sdk实例
7031
+ /** {en}
7032
+ * @brief Subtitle source. Business-configured subtitles use `config`; Master M3U8 or native HLS subtitles use `hls`.
7033
+ * @default config
6633
7034
  */
6634
- sdk: VePlayer;
6635
- /**
6636
- * @brief 当前加密播放类型,为空则表示非加密
7035
+ source?: "config" | "hls";
7036
+ /** {zh}
7037
+ * @brief 字幕语言。
7038
+ * @default -
6637
7039
  */
6638
- drmType: EDRMTYPE;
6639
- /**
6640
- * @brief 私有加密会话id
7040
+ /** {en}
7041
+ * @brief Subtitle language.
7042
+ * @default -
6641
7043
  */
6642
- encryptSessionId?: string;
7044
+ language?: string | number;
7045
+ /** {zh}
7046
+ * @brief 字幕 ID。
7047
+ * @default -
7048
+ */
7049
+ /** {en}
7050
+ * @brief Subtitle ID.
7051
+ * @default -
7052
+ */
7053
+ id?: number | string;
7054
+ /** {zh}
7055
+ * @brief 是否为默认选择的字幕。
7056
+ * @default false
7057
+ */
7058
+ /** {en}
7059
+ * @brief Whether this is the default selected subtitle.
7060
+ * @default false
7061
+ */
7062
+ isDefault?: boolean;
7063
+ /** {zh}
7064
+ * @brief 是否为强制字幕轨。
7065
+ * @default false
7066
+ */
7067
+ /** {en}
7068
+ * @brief Whether the subtitle track is forced.
7069
+ * @default false
7070
+ */
7071
+ forced?: boolean;
7072
+ /** {zh}
7073
+ * @brief HLS 字幕轨的特征标识,例如无障碍字幕特征;未声明时为空。
7074
+ * @default -
7075
+ */
7076
+ /** {en}
7077
+ * @brief HLS subtitle-track characteristics, such as accessibility traits; absent when not declared.
7078
+ * @default -
7079
+ */
7080
+ characteristics?: string;
7081
+ /** {zh}
7082
+ * @brief 字幕名称。
7083
+ * @default -
7084
+ */
7085
+ /** {en}
7086
+ * @brief Subtitle display name.
7087
+ * @default -
7088
+ */
7089
+ text?: string;
7090
+ /** {zh}
7091
+ * @brief 字幕名称。兼容 xgplayer-subtitles 的 label 字段。
7092
+ * @default -
7093
+ */
7094
+ /** {en}
7095
+ * @brief 字幕名称。兼容 xgplayer-subtitles 的 label 字段。
7096
+ * @default -
7097
+ */
7098
+ label?: string | number;
7099
+ /** {zh}
7100
+ * @brief 外挂字幕 URL 地址。
7101
+ * @default -
7102
+ */
7103
+ /** {en}
7104
+ * @brief External subtitle URL.
7105
+ * @default -
7106
+ */
7107
+ url?: string;
7108
+ /**
7109
+ * @hidden
7110
+ * @type {string}
7111
+ * @memberof ISubTitleItem
7112
+ */
7113
+ stringContent?: string;
7114
+ /** {zh}
7115
+ * @brief 字幕内容列表。非 `url` 形式时使用。
7116
+ * @default -
7117
+ * @type {Array<Object>}
7118
+ * @memberof ISubTitleItem
7119
+ */
7120
+ /** {en}
7121
+ * @brief Subtitle content list when not using URL.
7122
+ * @default -
7123
+ * @type {Array<Object>}
7124
+ * @memberof ISubTitleItem
7125
+ */
7126
+ list?: IListItem[];
7127
+ }
7128
+ /** {zh}
7129
+ * @brief 字幕内容项。
7130
+ * @list Options
7131
+ * @kind property
7132
+ * @export
7133
+ * @interface IListItem
7134
+ */
7135
+ /** {en}
7136
+ * @brief Subtitle content item.
7137
+ * @list Options
7138
+ * @kind property
7139
+ * @export
7140
+ * @interface IListItem
7141
+ */
7142
+ export interface IListItem {
7143
+ /** {zh}
7144
+ * @brief 开始时间,单位为秒。
7145
+ * @type {number}
7146
+ */
7147
+ /** {en}
7148
+ * @brief Start time in seconds.
7149
+ * @type {number}
7150
+ */
7151
+ start: number;
7152
+ /** {zh}
7153
+ * @brief 结束时间,单位为秒。
7154
+ * @type {number}
7155
+ */
7156
+ /** {en}
7157
+ * @brief End time in seconds.
7158
+ * @type {number}
7159
+ */
7160
+ end: number;
7161
+ /** {zh}
7162
+ * @brief 字幕数据列表。
7163
+ * @type {Array<ITextItem>}
7164
+ */
7165
+ /** {en}
7166
+ * @brief Subtitle cue data list.
7167
+ * @type {Array<ITextItem>}
7168
+ */
7169
+ list: Array<ITextItem>;
7170
+ /**
7171
+ * @hidden
7172
+ * @type {any}
7173
+ */
7174
+ [propName: string]: any;
7175
+ }
7176
+ /** {zh}
7177
+ * @brief 字幕文案配置。
7178
+ * @list Options
7179
+ * @kind property
7180
+ */
7181
+ /** {en}
7182
+ * @brief Subtitle text item configuration.
7183
+ * @list Options
7184
+ * @kind property
7185
+ */
7186
+ export interface ITextItem {
7187
+ /**
7188
+ * @hidden
7189
+ * @type {any}
7190
+ */
7191
+ [propName: string]: any;
7192
+ /** {zh}
7193
+ * @brief 开始时间,单位为秒。
7194
+ * @type {number}
7195
+ */
7196
+ /** {en}
7197
+ * @brief Start time in seconds.
7198
+ * @type {number}
7199
+ */
7200
+ start: number;
7201
+ /** {zh}
7202
+ * @brief 结束时间,单位为秒。
7203
+ * @type {number}
7204
+ */
7205
+ /** {en}
7206
+ * @brief End time in seconds.
7207
+ * @type {number}
7208
+ */
7209
+ end: number;
7210
+ /** {zh}
7211
+ * @brief 字幕文案数组。
7212
+ * @type {string[]}
7213
+ */
7214
+ /** {en}
7215
+ * @brief Subtitle text array.
7216
+ * @type {string[]}
7217
+ */
7218
+ text: string[];
7219
+ /** {zh}
7220
+ * @brief 字幕顺序。
7221
+ * @type {number}
7222
+ */
7223
+ /** {en}
7224
+ * @brief Subtitle display order.
7225
+ * @type {number}
7226
+ */
7227
+ index?: number;
7228
+ }
7229
+ /** {zh}
7230
+ * @brief HLS 自动码率决策引擎配置值。
7231
+ * @detail ref
7232
+ */
7233
+ /** {en}
7234
+ * @brief Configurable HLS adaptive-bitrate decision engine.
7235
+ * @detail ref
7236
+ */
7237
+ export type HlsAbrEngine = "hlsjs" | "veplayer";
7238
+ export type TLogChannel = "cn" | "va" | "sg";
7239
+ declare class PlayerData {
7240
+ id?: string;
7241
+ root?: HTMLElement;
7242
+ configs: IPlayerConfig;
7243
+ type: string;
7244
+ isLive: boolean;
7245
+ options: any;
7246
+ isMobile: boolean;
7247
+ playList: Stream[];
7248
+ plugins: any[];
7249
+ openSoftDecoding: boolean;
7250
+ defaultConfig: IDefaultConfig | undefined;
7251
+ isHitDefault: boolean;
7252
+ codec?: ICodecType;
7253
+ enableH265Degrade: boolean;
7254
+ languageData: {
7255
+ extraLangList: IXGI18nText[];
7256
+ extendLangList: IXGI18nText[];
7257
+ };
7258
+ current: Current;
7259
+ onMediaExpired: () => Promise<SourceConfig>;
7260
+ onTokenExpired: () => Promise<IPlayAuthTokenConfig>;
7261
+ unionId?: string;
7262
+ unionInfo?: string;
7263
+ isMusic?: boolean;
7264
+ sdkPlugins: any[];
7265
+ useHlsPluginForSafari: boolean;
7266
+ enableHlsJs: boolean;
7267
+ enableMenu: boolean;
7268
+ region: TRegionType;
7269
+ userRegion: TRegionType;
7270
+ playDomainDegrade: boolean;
7271
+ strategiesPlugins: any[];
7272
+ strategiesPluginConfigs: any;
7273
+ /**
7274
+ * @default playList第一项
7275
+ */
7276
+ defaultDefinition: string;
7277
+ urlCheckData: {
7278
+ enableUrlExpireCheck: boolean;
7279
+ urlExpireTimestamp: number;
7280
+ urlExpireDiff: number;
7281
+ urlCheckExpireInterval: number;
7282
+ };
7283
+ private isAutoBitrateEnable;
7284
+ adapter: AbstractBaseAdapter;
7285
+ /**
7286
+ * @breif 是否vid模式的加密播放
7287
+ */
7288
+ isVidEncrypt: boolean;
7289
+ dashOpts: {
7290
+ Data: IGetPlayInfoRes;
7291
+ };
7292
+ /**
7293
+ * @brief 播放器sdk实例
7294
+ */
7295
+ sdk: VePlayer;
7296
+ /**
7297
+ * @brief 当前加密播放类型,为空则表示非加密
7298
+ */
7299
+ drmType: EDRMTYPE;
7300
+ /**
7301
+ * @brief 私有加密会话id
7302
+ */
7303
+ encryptSessionId?: string;
6643
7304
  constructor(configs: IPlayerConfig, sdk: VePlayer);
6644
7305
  /**
6645
7306
  * 初始化播放数据
@@ -6676,6 +7337,8 @@ declare class PlayerData {
6676
7337
  */
6677
7338
  getCurrentStreamType(): string;
6678
7339
  getStreamType(): string;
7340
+ getConfiguredHlsAbrEngine(): HlsAbrEngine;
7341
+ isOpenVePlayerABR(): boolean;
6679
7342
  isOpenABR(): boolean;
6680
7343
  showRealDefinition(): boolean;
6681
7344
  isAutoDefinition(def: any): boolean;
@@ -7044,198 +7707,11 @@ export declare type IMediaInfoPrefetchFailure = {
7044
7707
  * @detail ref
7045
7708
  */
7046
7709
  /** {en}
7047
- * @brief Result for one media info prefetch item. Batch results preserve input order, and one failure does not interrupt other items.
7048
- * @detail ref
7049
- */
7050
- export declare type IMediaInfoPrefetchResult = IMediaInfoPrefetchSuccess | IMediaInfoPrefetchFailure;
7051
- export declare type IPreloadStream = IPreloadResolvedStream | IPreloadDramaStream | IPreloadAuthTokenStream;
7052
- /** {zh}
7053
- * @list Options
7054
- * @brief 字幕项。
7055
- * @kind property
7056
- */
7057
- /** {en}
7058
- * @list Options
7059
- * @brief Subtitle item.
7060
- * @kind property
7061
- */
7062
- export interface ISubTitleItem {
7063
- /** {zh}
7064
- * @brief 字幕语言。
7065
- * @default -
7066
- */
7067
- /** {en}
7068
- * @brief Subtitle language.
7069
- * @default -
7070
- */
7071
- language?: string | number;
7072
- /** {zh}
7073
- * @brief 字幕 ID。
7074
- * @default -
7075
- */
7076
- /** {en}
7077
- * @brief Subtitle ID.
7078
- * @default -
7079
- */
7080
- id?: number | string;
7081
- /** {zh}
7082
- * @brief 是否为默认选择的字幕。
7083
- * @default false
7084
- */
7085
- /** {en}
7086
- * @brief Whether this is the default selected subtitle.
7087
- * @default false
7088
- */
7089
- isDefault?: boolean;
7090
- /** {zh}
7091
- * @brief 字幕名称。
7092
- * @default -
7093
- */
7094
- /** {en}
7095
- * @brief Subtitle display name.
7096
- * @default -
7097
- */
7098
- text?: string;
7099
- /** {zh}
7100
- * @brief 字幕名称。兼容 xgplayer-subtitles 的 label 字段。
7101
- * @default -
7102
- */
7103
- /** {en}
7104
- * @brief 字幕名称。兼容 xgplayer-subtitles 的 label 字段。
7105
- * @default -
7106
- */
7107
- label?: string | number;
7108
- /** {zh}
7109
- * @brief 外挂字幕 URL 地址。
7110
- * @default -
7111
- */
7112
- /** {en}
7113
- * @brief External subtitle URL.
7114
- * @default -
7115
- */
7116
- url?: string;
7117
- /**
7118
- * @hidden
7119
- * @type {string}
7120
- * @memberof ISubTitleItem
7121
- */
7122
- stringContent?: string;
7123
- /** {zh}
7124
- * @brief 字幕内容列表。非 `url` 形式时使用。
7125
- * @default -
7126
- * @type {Array<Object>}
7127
- * @memberof ISubTitleItem
7128
- */
7129
- /** {en}
7130
- * @brief Subtitle content list when not using URL.
7131
- * @default -
7132
- * @type {Array<Object>}
7133
- * @memberof ISubTitleItem
7134
- */
7135
- list?: IListItem[];
7136
- }
7137
- /** {zh}
7138
- * @brief 字幕内容项。
7139
- * @list Options
7140
- * @kind property
7141
- * @export
7142
- * @interface IListItem
7143
- */
7144
- /** {en}
7145
- * @brief Subtitle content item.
7146
- * @list Options
7147
- * @kind property
7148
- * @export
7149
- * @interface IListItem
7150
- */
7151
- export interface IListItem {
7152
- /** {zh}
7153
- * @brief 开始时间,单位为秒。
7154
- * @type {number}
7155
- */
7156
- /** {en}
7157
- * @brief Start time in seconds.
7158
- * @type {number}
7159
- */
7160
- start: number;
7161
- /** {zh}
7162
- * @brief 结束时间,单位为秒。
7163
- * @type {number}
7164
- */
7165
- /** {en}
7166
- * @brief End time in seconds.
7167
- * @type {number}
7168
- */
7169
- end: number;
7170
- /** {zh}
7171
- * @brief 字幕数据列表。
7172
- * @type {Array<ITextItem>}
7173
- */
7174
- /** {en}
7175
- * @brief Subtitle cue data list.
7176
- * @type {Array<ITextItem>}
7177
- */
7178
- list: Array<ITextItem>;
7179
- /**
7180
- * @hidden
7181
- * @type {any}
7182
- */
7183
- [propName: string]: any;
7184
- }
7185
- /** {zh}
7186
- * @brief 字幕文案配置。
7187
- * @list Options
7188
- * @kind property
7189
- */
7190
- /** {en}
7191
- * @brief Subtitle text item configuration.
7192
- * @list Options
7193
- * @kind property
7710
+ * @brief Result for one media info prefetch item. Batch results preserve input order, and one failure does not interrupt other items.
7711
+ * @detail ref
7194
7712
  */
7195
- export interface ITextItem {
7196
- /**
7197
- * @hidden
7198
- * @type {any}
7199
- */
7200
- [propName: string]: any;
7201
- /** {zh}
7202
- * @brief 开始时间,单位为秒。
7203
- * @type {number}
7204
- */
7205
- /** {en}
7206
- * @brief Start time in seconds.
7207
- * @type {number}
7208
- */
7209
- start: number;
7210
- /** {zh}
7211
- * @brief 结束时间,单位为秒。
7212
- * @type {number}
7213
- */
7214
- /** {en}
7215
- * @brief End time in seconds.
7216
- * @type {number}
7217
- */
7218
- end: number;
7219
- /** {zh}
7220
- * @brief 字幕文案数组。
7221
- * @type {string[]}
7222
- */
7223
- /** {en}
7224
- * @brief Subtitle text array.
7225
- * @type {string[]}
7226
- */
7227
- text: string[];
7228
- /** {zh}
7229
- * @brief 字幕顺序。
7230
- * @type {number}
7231
- */
7232
- /** {en}
7233
- * @brief Subtitle display order.
7234
- * @type {number}
7235
- */
7236
- index?: number;
7237
- }
7238
- export type TLogChannel = "cn" | "va" | "sg";
7713
+ export declare type IMediaInfoPrefetchResult = IMediaInfoPrefetchSuccess | IMediaInfoPrefetchFailure;
7714
+ export declare type IPreloadStream = IPreloadResolvedStream | IPreloadDramaStream | IPreloadAuthTokenStream;
7239
7715
  /** {zh}
7240
7716
  * @hidden
7241
7717
  * h265策略配置
@@ -7743,6 +8219,14 @@ declare class VePlayer {
7743
8219
  * @memberof VePlayer
7744
8220
  */
7745
8221
  private _emitter;
8222
+ /** @hidden 当前播放内核对应的 Master M3U8 Level 控制器。 */
8223
+ private _hlsMasterController;
8224
+ /** @hidden 当前播放内核对应的 Master M3U8 字幕适配器。 */
8225
+ private _hlsSubtitleAdapter;
8226
+ /** @hidden 当前播放世代中业务显式配置的字幕列表快照。 */
8227
+ private _explicitSubtitleListSnapshot;
8228
+ /** @hidden 在播放会话提交后刷新 Level 快照与事件归属。 */
8229
+ private _hlsMasterRefreshListener?;
7746
8230
  /** 最近一次用户选择的音轨,用于清晰度切换后通过 setAudioOption 恢复音轨 */
7747
8231
  private _lastSelectedAudioTrack;
7748
8232
  /**
@@ -8301,6 +8785,14 @@ declare class VePlayer {
8301
8785
  * @memberof VePlayer
8302
8786
  */
8303
8787
  afterPlayerCreate(): void;
8788
+ /** @hidden 为当前播放内核挂载会话隔离的 Master M3U8 Level 控制器。 */
8789
+ private _mountHlsMasterController;
8790
+ /** @hidden 为当前 hls.js 播放会话挂载安全的 Master 字幕适配器。 */
8791
+ private _mountHlsSubtitleAdapter;
8792
+ /** @hidden 克隆业务字幕策略,避免由运行时注入列表反推来源。 */
8793
+ private _cloneExplicitSubtitleList;
8794
+ /** @hidden 返回稳定的 Level 会话刷新监听器,便于销毁时精确解绑。 */
8795
+ private _getHlsMasterRefreshListener;
8304
8796
  _setVeError(): void;
8305
8797
  /**
8306
8798
  * @hidden
@@ -8621,6 +9113,171 @@ declare class VePlayer {
8621
9113
  selected: boolean;
8622
9114
  [propName: string]: any;
8623
9115
  }>;
9116
+ /** {zh}
9117
+ * @brief 获取当前播放会话中由 Master M3U8 解析出的 HLS Level 列表。
9118
+ * @list Api
9119
+ * @returns 标准化后的 HLS Level 快照;Manifest 未就绪或当前不是 hls.js 内核时返回空数组。
9120
+ * @notes Level 的 `index` 只在当前 `playbackSessionId` 内有效;返回结果不包含播放地址和鉴权信息。
9121
+ * @example
9122
+ * ``` javascript
9123
+ * const levels = playerSdkIns.getHlsLevels();
9124
+ * console.log(levels.map(level => `${level.height}p`));
9125
+ * ```
9126
+ */
9127
+ /** {en}
9128
+ * @brief Get HLS Levels parsed from the Master M3U8 for the current playback session.
9129
+ * @list Api
9130
+ * @returns A normalized HLS Level snapshot. Returns an empty array before the manifest is ready or when hls.js is not the active engine.
9131
+ * @notes A Level `index` is valid only for the current `playbackSessionId`. Playback URLs and authorization data are never returned.
9132
+ * @example
9133
+ * ``` javascript
9134
+ * const levels = playerSdkIns.getHlsLevels();
9135
+ * console.log(levels.map(level => `${level.height}p`));
9136
+ * ```
9137
+ */
9138
+ getHlsLevels(): IHlsLevel[];
9139
+ /** {zh}
9140
+ * @brief 获取当前播放会话的 HLS Level 状态。
9141
+ * @list Api
9142
+ * @returns HLS Level 状态快照,包含列表就绪状态、实际档位、手动档位和自动选档上限。
9143
+ * @notes `READY` 事件不表示 Level 列表已经就绪;请检查返回值的 `ready`,或监听 `HLS_LEVELS_UPDATED`。
9144
+ * @example
9145
+ * ``` javascript
9146
+ * const state = playerSdkIns.getHlsLevelState();
9147
+ * if (state.ready) {
9148
+ * console.log(state.currentLevel, state.autoLevelEnabled);
9149
+ * }
9150
+ * ```
9151
+ */
9152
+ /** {en}
9153
+ * @brief Get HLS Level state for the current playback session.
9154
+ * @list Api
9155
+ * @returns An HLS Level state snapshot including readiness, active and manual Levels, and the automatic Level cap.
9156
+ * @notes The `READY` event does not mean the Level list is ready. Check `ready` or listen for `HLS_LEVELS_UPDATED`.
9157
+ * @example
9158
+ * ``` javascript
9159
+ * const state = playerSdkIns.getHlsLevelState();
9160
+ * if (state.ready) {
9161
+ * console.log(state.currentLevel, state.autoLevelEnabled);
9162
+ * }
9163
+ * ```
9164
+ */
9165
+ getHlsLevelState(): IHlsLevelState;
9166
+ /** {zh}
9167
+ * @brief 手动切换当前 Master M3U8 的 HLS Level。
9168
+ * @list Api
9169
+ * @param levelIndex 目标 Level 索引,可通过 `getHlsLevels()` 获取。
9170
+ * @param options 切换模式和可选的播放会话 ID。
9171
+ * @notes 调用后进入手动选档。目标提交时触发 `HLS_LEVEL_SWITCHING`,实际生效后触发 `HLS_LEVEL_SWITCHED`。Manifest 未就绪、内核不支持、索引越界或会话过期时抛出 {@link HlsControlError}。
9172
+ * @example
9173
+ * ``` javascript
9174
+ * const state = playerSdkIns.getHlsLevelState();
9175
+ * playerSdkIns.setHlsLevel(1, {
9176
+ * mode: 'next-fragment',
9177
+ * playbackSessionId: state.playbackSessionId
9178
+ * });
9179
+ * ```
9180
+ */
9181
+ /** {en}
9182
+ * @brief Manually switch the HLS Level in the current Master M3U8.
9183
+ * @list Api
9184
+ * @param levelIndex Target Level index from `getHlsLevels()`.
9185
+ * @param options Switching mode and optional playback session ID.
9186
+ * @notes Calling this method enters manual Level selection. `HLS_LEVEL_SWITCHING` fires when submitted, and `HLS_LEVEL_SWITCHED` fires after it takes effect. A {@link HlsControlError} is thrown when the manifest is not ready, the engine is unsupported, the index is invalid, or the session has expired.
9187
+ * @example
9188
+ * ``` javascript
9189
+ * const state = playerSdkIns.getHlsLevelState();
9190
+ * playerSdkIns.setHlsLevel(1, {
9191
+ * mode: 'next-fragment',
9192
+ * playbackSessionId: state.playbackSessionId
9193
+ * });
9194
+ * ```
9195
+ */
9196
+ setHlsLevel(levelIndex: number, options?: IHlsLevelSwitchOptions): void;
9197
+ /** {zh}
9198
+ * @brief 获取当前播放会话的 HLS ABR 引擎、模式、可用性和控制能力。
9199
+ * @list Api
9200
+ * @returns 当前 HLS ABR 状态快照。
9201
+ * @notes `engine` 是实际解析出的决策引擎;`configuredEngine` 只表示已生效的显式配置。请使用 `decisionSource` 决定清晰度 UI 展示 Level 还是 Definition。
9202
+ * @example
9203
+ * ``` javascript
9204
+ * const state = playerSdkIns.getHlsAbrState();
9205
+ * console.log(state.engine, state.mode, state.decisionSource);
9206
+ * ```
9207
+ */
9208
+ /** {en}
9209
+ * @brief Get the HLS ABR engine, mode, availability, and capabilities for the current playback session.
9210
+ * @list Api
9211
+ * @returns The current HLS ABR state snapshot.
9212
+ * @notes `engine` is the resolved decision engine, while `configuredEngine` only represents an effective explicit configuration. Use `decisionSource` to choose Levels or Definitions in a quality UI.
9213
+ * @example
9214
+ * ``` javascript
9215
+ * const state = playerSdkIns.getHlsAbrState();
9216
+ * console.log(state.engine, state.mode, state.decisionSource);
9217
+ * ```
9218
+ */
9219
+ getHlsAbrState(): IHlsAbrState;
9220
+ /** {zh}
9221
+ * @brief 设置当前播放会话的 HLS ABR 自动或手动模式。
9222
+ * @list Api
9223
+ * @param mode ABR 模式。
9224
+ * @notes 设置为 `auto` 时恢复当前已解析出的 ABR 引擎,不保证固定使用 hls.js。设置为 `manual` 本身不选择档位,需配合 `setHlsLevel()` 或 Definition API。
9225
+ * @example
9226
+ * ``` javascript
9227
+ * playerSdkIns.setHlsAbrMode('auto');
9228
+ * ```
9229
+ */
9230
+ /** {en}
9231
+ * @brief Set automatic or manual HLS ABR mode for the current playback session.
9232
+ * @list Api
9233
+ * @param mode ABR mode.
9234
+ * @notes `auto` restores the resolved ABR engine and does not necessarily select hls.js. `manual` does not select a rendition by itself; use `setHlsLevel()` or a Definition API afterwards.
9235
+ * @example
9236
+ * ``` javascript
9237
+ * playerSdkIns.setHlsAbrMode('auto');
9238
+ * ```
9239
+ */
9240
+ setHlsAbrMode(mode: HlsAbrMode): void;
9241
+ /** {zh}
9242
+ * @brief 获取当前播放会话已设置的 HLS ABR 上限。
9243
+ * @list Api
9244
+ * @returns 当前上限的副本;未设置时返回 `null`。
9245
+ * @example
9246
+ * ``` javascript
9247
+ * console.log(playerSdkIns.getHlsAbrLimit());
9248
+ * ```
9249
+ */
9250
+ /** {en}
9251
+ * @brief Get the HLS ABR limit configured for the current playback session.
9252
+ * @list Api
9253
+ * @returns A copy of the current limit, or `null` when no limit is set.
9254
+ * @example
9255
+ * ``` javascript
9256
+ * console.log(playerSdkIns.getHlsAbrLimit());
9257
+ * ```
9258
+ */
9259
+ getHlsAbrLimit(): IHlsAbrLimit;
9260
+ /** {zh}
9261
+ * @brief 设置或清除当前播放会话的 HLS ABR 上限。
9262
+ * @list Api
9263
+ * @param limit Level、码率或 Definition 上限;传入 `null` 清除上限。
9264
+ * @notes 是否支持某种上限取决于 `getHlsAbrState().capabilities`;无法安全映射时抛出 {@link HlsControlError},原上限保持不变。
9265
+ * @example
9266
+ * ``` javascript
9267
+ * playerSdkIns.setHlsAbrLimit({ type: 'bitrate', maxBitrate: 2500000 });
9268
+ * ```
9269
+ */
9270
+ /** {en}
9271
+ * @brief Set or clear the HLS ABR limit for the current playback session.
9272
+ * @list Api
9273
+ * @param limit A Level, bitrate, or Definition cap. Pass `null` to clear it.
9274
+ * @notes Supported limit kinds are reported by `getHlsAbrState().capabilities`. A {@link HlsControlError} is thrown when a limit cannot be mapped safely, and the previous limit remains unchanged.
9275
+ * @example
9276
+ * ``` javascript
9277
+ * playerSdkIns.setHlsAbrLimit({ type: 'bitrate', maxBitrate: 2500000 });
9278
+ * ```
9279
+ */
9280
+ setHlsAbrLimit(limit: IHlsAbrLimit): void;
8624
9281
  /** {zh}
8625
9282
  * @brief 获取音频轨道列表。HLS 流通过 hls.js 获取,iOS 原生播放通过 HTMLMediaElement.audioTracks 获取。
8626
9283
  * @notes 每项包含 `id`、`name`、`lang`、`channels`、`default`、`selected` 字段;轨道数量 ≤ 1 时返回空数组。
@@ -8896,16 +9553,51 @@ declare class VePlayer {
8896
9553
  */
8897
9554
  getPlugin(pluginName: string): null | BasePlugin;
8898
9555
  /** {zh}
8899
- * @brief 获取字幕列表。需配置 `Subtitle` 插件后调用。
8900
- * @return 当前字幕列表,每项包含 `id`、`language`、`text`(显示名称)等字段。列表为空时返回空数组。
8901
- * @memberof VePlayer
9556
+ * @brief 获取当前字幕列表。
9557
+ * @list Api
9558
+ * @returns 当前字幕列表的副本;未注册 `Subtitle` 插件或列表未就绪时返回空数组。
9559
+ * @notes Master M3U8 字幕项的 `source` 为 `hls`,不包含播放地址或底层轨道索引;业务显式配置的非空字幕列表优先。
9560
+ * @example
9561
+ * ``` javascript
9562
+ * const subtitles = playerSdkIns.getSubtitleList();
9563
+ * console.log(subtitles.map(item => item.text));
9564
+ * ```
9565
+ */
9566
+ /** {en}
9567
+ * @brief Get the current subtitle list.
9568
+ * @list Api
9569
+ * @returns A copy of the current subtitle list, or an empty array when the `Subtitle` plugin is unavailable or the list is not ready.
9570
+ * @notes Master M3U8 subtitle items use `source: 'hls'` and do not expose playback URLs or internal track indexes. A non-empty business-configured subtitle list takes precedence.
9571
+ * @example
9572
+ * ``` javascript
9573
+ * const subtitles = playerSdkIns.getSubtitleList();
9574
+ * console.log(subtitles.map(item => item.text));
9575
+ * ```
8902
9576
  */
8903
9577
  getSubtitleList(): ISubTitleItem[];
8904
9578
  /** {zh}
8905
- * @brief 切换字幕。需配置 `Subtitle` 插件后调用。
8906
- * @param subtitle 目标字幕的 id 或 language,任意一个非空即可定位字幕项。
8907
- * @return 切换成功时 resolve,失败(未找到、切换被中止)时 reject。
8908
- * @memberof VePlayer
9579
+ * @brief 切换当前字幕轨。
9580
+ * @list Api
9581
+ * @param subtitle 目标字幕的 `id` 或 `language`。优先精确匹配 `id`;仅按语言切换时必须唯一。
9582
+ * @returns 切换成功时 resolve;未找到、语言不唯一、切换超时或播放会话失效时 reject。
9583
+ * @notes hls.js 模式下,Promise 在播放内核确认目标字幕轨后才 resolve。
9584
+ * @example
9585
+ * ``` javascript
9586
+ * const [subtitle] = playerSdkIns.getSubtitleList();
9587
+ * if (subtitle) await playerSdkIns.switchSubtitle({ id: subtitle.id });
9588
+ * ```
9589
+ */
9590
+ /** {en}
9591
+ * @brief Switch the active subtitle track.
9592
+ * @list Api
9593
+ * @param subtitle Target subtitle `id` or `language`. Exact `id` matching takes precedence; a language-only match must be unique.
9594
+ * @returns Resolves after a successful switch. Rejects when the track is missing, the language is ambiguous, the switch times out, or the playback session expires.
9595
+ * @notes In hls.js mode, the Promise resolves only after the playback engine confirms the target subtitle track.
9596
+ * @example
9597
+ * ``` javascript
9598
+ * const [subtitle] = playerSdkIns.getSubtitleList();
9599
+ * if (subtitle) await playerSdkIns.switchSubtitle({ id: subtitle.id });
9600
+ * ```
8909
9601
  */
8910
9602
  switchSubtitle(subtitle: {
8911
9603
  id?: string | number;
@@ -8913,12 +9605,36 @@ declare class VePlayer {
8913
9605
  }): Promise<void>;
8914
9606
  /** {zh}
8915
9607
  * @brief 开启字幕展示。恢复上次选中的字幕项;若从未选中过则默认选第一项。需配置 `Subtitle` 插件后调用。
8916
- * @memberof VePlayer
9608
+ * @list Api
9609
+ * @example
9610
+ * ``` javascript
9611
+ * playerSdkIns.showSubtitle();
9612
+ * ```
9613
+ */
9614
+ /** {en}
9615
+ * @brief Show subtitles by restoring the last selected item, or the first item when none has been selected. Requires the `Subtitle` plugin.
9616
+ * @list Api
9617
+ * @example
9618
+ * ``` javascript
9619
+ * playerSdkIns.showSubtitle();
9620
+ * ```
8917
9621
  */
8918
9622
  showSubtitle(): void;
8919
9623
  /** {zh}
8920
9624
  * @brief 关闭字幕展示。字幕数据保留,可通过 `showSubtitle` 重新开启。需配置 `Subtitle` 插件后调用。
8921
- * @memberof VePlayer
9625
+ * @list Api
9626
+ * @example
9627
+ * ``` javascript
9628
+ * playerSdkIns.hideSubtitle();
9629
+ * ```
9630
+ */
9631
+ /** {en}
9632
+ * @brief Hide subtitles while retaining subtitle data so it can be restored with `showSubtitle`. Requires the `Subtitle` plugin.
9633
+ * @list Api
9634
+ * @example
9635
+ * ``` javascript
9636
+ * playerSdkIns.hideSubtitle();
9637
+ * ```
8922
9638
  */
8923
9639
  hideSubtitle(): void;
8924
9640
  /** {zh}
@@ -9086,12 +9802,21 @@ export declare class LiveSubtitlesIconPlugin extends Plugin {
9086
9802
  destroy(): void;
9087
9803
  render(): string;
9088
9804
  }
9805
+ export declare type NativeSubTitleOptions = {
9806
+ nativeRenderMode?: "system" | "dom";
9807
+ container?: HTMLElement;
9808
+ style?: ISubtitleStyle;
9809
+ playbackSessionId?: string;
9810
+ emit?: (event: string, payload: unknown) => void;
9811
+ createOpaqueId?: () => string;
9812
+ };
9089
9813
  declare class NativeSubTitle extends EventEmitter {
9090
9814
  _media: any;
9091
9815
  _list: any[];
9092
9816
  _languages: string;
9093
9817
  curIndex: number;
9094
- constructor(media: any);
9818
+ private _domAdapter?;
9819
+ constructor(media: any, options?: NativeSubTitleOptions);
9095
9820
  _init(): void;
9096
9821
  _onChange: (e: any) => void;
9097
9822
  /**
@@ -9105,6 +9830,8 @@ declare class NativeSubTitle extends EventEmitter {
9105
9830
  switch(data: any): Promise<unknown>;
9106
9831
  switchOff(): void;
9107
9832
  destroy(): void;
9833
+ refresh(): void;
9834
+ setPlaybackSessionId(playbackSessionId: string): void;
9108
9835
  }
9109
9836
  export interface IPanelItem {
9110
9837
  showText: string;
@@ -9136,6 +9863,7 @@ export declare class Subtitle extends Plugin {
9136
9863
  };
9137
9864
  isShowIcon: boolean;
9138
9865
  mode: string;
9866
+ nativeRenderMode: string;
9139
9867
  updateMode: string;
9140
9868
  };
9141
9869
  private _delegates;
@@ -9148,6 +9876,11 @@ export declare class Subtitle extends Plugin {
9148
9876
  player: Player & {
9149
9877
  _subTitles?: NativeSubTitle | SubTitles;
9150
9878
  };
9879
+ private _hideListTimer;
9880
+ private _optionListEnterHandler?;
9881
+ private _optionListLeaveHandler?;
9882
+ private _runtimeSubtitleSource;
9883
+ private _runtimeSubtitleBridge?;
9151
9884
  afterCreate(): void;
9152
9885
  /**
9153
9886
  * @description 初始化原生字幕
@@ -9159,6 +9892,7 @@ export declare class Subtitle extends Plugin {
9159
9892
  * @param {number} defaultIndex
9160
9893
  */
9161
9894
  _initExtSubTitle(defaultIndex: any): void;
9895
+ private protectExtSubtitleCoreEvents;
9162
9896
  _renderList(defaultIndex: any): void;
9163
9897
  _onOff: () => void;
9164
9898
  _onChange: (data: any) => void;
@@ -9166,15 +9900,30 @@ export declare class Subtitle extends Plugin {
9166
9900
  updateCurItem(cIndex: any, subtitle: any): void;
9167
9901
  initEvents(): void;
9168
9902
  handleButtonChange: (e: any) => void;
9903
+ private runUiSubtitleAction;
9169
9904
  onEnter: (e: any) => void;
9170
9905
  onLeave: (e: any) => void;
9906
+ private clearPendingListHide;
9907
+ private scheduleListHide;
9908
+ private bindOptionListHoverEvents;
9909
+ private unbindOptionListHoverEvents;
9171
9910
  showList(): void;
9172
9911
  hideList(): void;
9173
9912
  openSubtitle(): Promise<any>;
9174
- getSubTitleIndex(list: any, subtitle?: {
9175
- id: string;
9176
- language: string;
9177
- }): number;
9913
+ getSubTitleIndex(list: ISubTitleItem[], subtitle?: Pick<ISubTitleItem, "id" | "language">): number;
9914
+ setRuntimeSubtitleSource(source: "config" | "hls"): void;
9915
+ setRuntimeSubtitleBridge(bridge?: {
9916
+ switchSubtitle: (subtitle: {
9917
+ id?: string | number;
9918
+ language?: string | number;
9919
+ }) => Promise<void>;
9920
+ hide: () => void;
9921
+ show: () => Promise<void>;
9922
+ }): void;
9923
+ replaceRuntimeSubtitleList(list: ISubTitleItem[], isOpen: boolean): void;
9924
+ confirmRuntimeSubtitleSelection(item: ISubTitleItem | null): void;
9925
+ syncRuntimeSubtitleRenderer(runtimeIndex: number): void;
9926
+ clearRuntimeSubtitleView(): void;
9178
9927
  registerIcons(): {
9179
9928
  vttSubOpen: {
9180
9929
  icon: string;
@@ -9952,6 +10701,69 @@ export declare const Events: {
9952
10701
  * @brief Triggered when audio track switching completes. `data.id` is the new track id; `data.audioTrack` is the full track object.
9953
10702
  */
9954
10703
  AUDIO_TRACK_CHANGE: string;
10704
+ /** {zh}
10705
+ * @brief 当前播放会话的 HLS Level 列表或状态更新。
10706
+ */
10707
+ /** {en}
10708
+ * @brief Triggered when the HLS Level list or state updates for the current playback session.
10709
+ */
10710
+ HLS_LEVELS_UPDATED: string;
10711
+ /** {zh}
10712
+ * @brief HLS Level 切换请求已提交给播放内核;不表示画面已经切换。
10713
+ */
10714
+ /** {en}
10715
+ * @brief Triggered after an HLS Level switch is submitted to the playback engine; the rendered Level may not have changed yet.
10716
+ */
10717
+ HLS_LEVEL_SWITCHING: string;
10718
+ /** {zh}
10719
+ * @brief HLS Level 已实际切换。
10720
+ */
10721
+ /** {en}
10722
+ * @brief Triggered after the active HLS Level has actually switched.
10723
+ */
10724
+ HLS_LEVEL_SWITCHED: string;
10725
+ /** {zh}
10726
+ * @brief 当前播放会话的 HLS ABR 决策引擎解析完成。
10727
+ */
10728
+ /** {en}
10729
+ * @brief Triggered after the HLS ABR decision engine is resolved for the current playback session.
10730
+ */
10731
+ HLS_ABR_ENGINE_RESOLVED: string;
10732
+ /** {zh}
10733
+ * @brief HLS ABR 的可用性、自动/手动模式或激活状态发生变化。
10734
+ */
10735
+ /** {en}
10736
+ * @brief Triggered when HLS ABR availability, auto/manual mode, or active state changes.
10737
+ */
10738
+ HLS_ABR_STATE_CHANGE: string;
10739
+ /** {zh}
10740
+ * @brief HLS ABR 上限发生变化。
10741
+ */
10742
+ /** {en}
10743
+ * @brief Triggered when the HLS ABR cap changes.
10744
+ */
10745
+ HLS_ABR_LIMIT_CHANGE: string;
10746
+ /** {zh}
10747
+ * @brief 当前播放会话从 Master M3U8 或原生 TextTrack 获得的字幕列表更新。
10748
+ */
10749
+ /** {en}
10750
+ * @brief Triggered when the subtitle list sourced from a Master M3U8 or native TextTracks updates for the current playback session.
10751
+ */
10752
+ HLS_SUBTITLE_TRACKS_UPDATED: string;
10753
+ /** {zh}
10754
+ * @brief HLS 字幕轨切换请求已提交;不表示字幕轨已经生效。
10755
+ */
10756
+ /** {en}
10757
+ * @brief Triggered after an HLS subtitle-track switch is submitted; the track may not be active yet.
10758
+ */
10759
+ HLS_SUBTITLE_TRACK_SWITCHING: string;
10760
+ /** {zh}
10761
+ * @brief HLS 字幕轨切换已经生效。
10762
+ */
10763
+ /** {en}
10764
+ * @brief Triggered after an HLS subtitle-track switch takes effect.
10765
+ */
10766
+ HLS_SUBTITLE_TRACK_SWITCHED: string;
9955
10767
  /** {zh}
9956
10768
  * @brief 在播放被终止时触发。例如当播放中的视频重新开始播放。
9957
10769
  */
@@ -10397,6 +11209,69 @@ export declare const Event: {
10397
11209
  * @brief Triggered when audio track switching completes. `data.id` is the new track id; `data.audioTrack` is the full track object.
10398
11210
  */
10399
11211
  AUDIO_TRACK_CHANGE: string;
11212
+ /** {zh}
11213
+ * @brief 当前播放会话的 HLS Level 列表或状态更新。
11214
+ */
11215
+ /** {en}
11216
+ * @brief Triggered when the HLS Level list or state updates for the current playback session.
11217
+ */
11218
+ HLS_LEVELS_UPDATED: string;
11219
+ /** {zh}
11220
+ * @brief HLS Level 切换请求已提交给播放内核;不表示画面已经切换。
11221
+ */
11222
+ /** {en}
11223
+ * @brief Triggered after an HLS Level switch is submitted to the playback engine; the rendered Level may not have changed yet.
11224
+ */
11225
+ HLS_LEVEL_SWITCHING: string;
11226
+ /** {zh}
11227
+ * @brief HLS Level 已实际切换。
11228
+ */
11229
+ /** {en}
11230
+ * @brief Triggered after the active HLS Level has actually switched.
11231
+ */
11232
+ HLS_LEVEL_SWITCHED: string;
11233
+ /** {zh}
11234
+ * @brief 当前播放会话的 HLS ABR 决策引擎解析完成。
11235
+ */
11236
+ /** {en}
11237
+ * @brief Triggered after the HLS ABR decision engine is resolved for the current playback session.
11238
+ */
11239
+ HLS_ABR_ENGINE_RESOLVED: string;
11240
+ /** {zh}
11241
+ * @brief HLS ABR 的可用性、自动/手动模式或激活状态发生变化。
11242
+ */
11243
+ /** {en}
11244
+ * @brief Triggered when HLS ABR availability, auto/manual mode, or active state changes.
11245
+ */
11246
+ HLS_ABR_STATE_CHANGE: string;
11247
+ /** {zh}
11248
+ * @brief HLS ABR 上限发生变化。
11249
+ */
11250
+ /** {en}
11251
+ * @brief Triggered when the HLS ABR cap changes.
11252
+ */
11253
+ HLS_ABR_LIMIT_CHANGE: string;
11254
+ /** {zh}
11255
+ * @brief 当前播放会话从 Master M3U8 或原生 TextTrack 获得的字幕列表更新。
11256
+ */
11257
+ /** {en}
11258
+ * @brief Triggered when the subtitle list sourced from a Master M3U8 or native TextTracks updates for the current playback session.
11259
+ */
11260
+ HLS_SUBTITLE_TRACKS_UPDATED: string;
11261
+ /** {zh}
11262
+ * @brief HLS 字幕轨切换请求已提交;不表示字幕轨已经生效。
11263
+ */
11264
+ /** {en}
11265
+ * @brief Triggered after an HLS subtitle-track switch is submitted; the track may not be active yet.
11266
+ */
11267
+ HLS_SUBTITLE_TRACK_SWITCHING: string;
11268
+ /** {zh}
11269
+ * @brief HLS 字幕轨切换已经生效。
11270
+ */
11271
+ /** {en}
11272
+ * @brief Triggered after an HLS subtitle-track switch takes effect.
11273
+ */
11274
+ HLS_SUBTITLE_TRACK_SWITCHED: string;
10400
11275
  };
10401
11276
  PluginEvents: {
10402
11277
  /** {zh}