UNPKG

vnetwork-player

Version:

A React component custom player support video m3u8, mp4

81 lines (80 loc) 3.82 kB
export declare type HlsLevel = { height?: number; url?: string | string[]; }; export declare type HlsManifestParsedData = { levels?: HlsLevel[]; }; export declare type HlsLevelSwitchedData = { level?: number; }; export declare type HlsInstance = { startLevel: number; currentLevel: number; liveSyncPosition?: number | null; loadSource: (source: string) => void; startLoad: () => void; destroy: () => void; attachMedia: (media: HTMLMediaElement) => void; on: (event: string, callback: (event: string, data: HlsManifestParsedData & HlsLevelSwitchedData) => void) => void; }; export declare type HlsConstructorLike = { new (): HlsInstance; isSupported: () => boolean; Events: { MANIFEST_PARSED: string; LEVEL_SWITCHED: string; }; }; export declare const HLS_AUTO_LEVEL = -1; export declare const AUTO_QUALITY_STALL_WINDOW_MS = 10000; export declare const AUTO_QUALITY_STALL_LIMIT = 1; export declare const AUTO_QUALITY_LONG_STALL_MS = 1500; export declare const AUTO_QUALITY_SWITCH_COOLDOWN_MS = 5000; export declare const AUTO_QUALITY_SWITCH_GRACE_MS = 2000; export declare const AUTO_QUALITY_UPGRADE_BUFFER_SECONDS = 8; export declare const AUTO_QUALITY_UPGRADE_HEALTHY_MS = 8000; export declare const AUTO_QUALITY_CHECK_INTERVAL_MS = 1000; /** * Tuning knobs for the custom auto-quality monitor. This monitor only runs * when hls.js ABR is not in charge, i.e. when the `source` prop is a * user-provided `Source[]` profile list (mp4 or per-profile m3u8 URLs). * For a single master m3u8 URL, hls.js handles adaptive switching natively * and this config is ignored. * * All fields are optional when passed through the `autoQualityConfig` prop; * missing fields fall back to DEFAULT_AUTO_QUALITY_CONFIG. */ export interface AutoQualityConfig { /** Sliding window (ms) in which stalls are counted. */ stallWindowMs: number; /** Number of stalls inside the window that triggers a downgrade. */ stallLimit: number; /** A single stall lasting longer than this (ms) triggers a downgrade. */ longStallMs: number; /** Minimum time (ms) between two automatic quality switches. */ switchCooldownMs: number; /** Stalls occurring within this time (ms) after a switch are ignored. */ switchGraceMs: number; /** Buffered seconds ahead of playback required before an upgrade. */ upgradeBufferSeconds: number; /** Time (ms) without any stall required before an upgrade. */ upgradeHealthyMs: number; /** How often (ms) the monitor evaluates an upgrade opportunity. */ checkIntervalMs: number; } export declare const DEFAULT_AUTO_QUALITY_CONFIG: AutoQualityConfig; export declare const resolveAutoQualityConfig: (config?: Partial<AutoQualityConfig> | undefined) => AutoQualityConfig; export declare const getBufferedAhead: (videoElement: HTMLVideoElement) => number; export declare const LIVE_EDGE_OFFSET_SECONDS = 0.5; export declare const LIVE_EDGE_CLICKABLE_THRESHOLD_SECONDS = 2; export declare type NormalizedSkipSegment = { start: number; end: number; label: string; }; export declare const getSeekableLivePosition: (videoElement: HTMLVideoElement) => number | null; export declare const getLivePosition: (videoElement: HTMLVideoElement, hls?: HlsInstance | null | undefined) => number | null; export declare const normalizeSkipIntro: (startIntro?: number | undefined, endIntro?: number | undefined) => NormalizedSkipSegment | null; export declare const normalizeSkipOutro: (startOutro?: number | undefined, endOutro?: number | undefined) => NormalizedSkipSegment | null; export declare const isSkipSegmentActive: (segment: NormalizedSkipSegment | null, currentTime: number) => boolean;