2026-02-27 09:50:13 +03:00
|
|
|
import Hls from "hls.js";
|
|
|
|
|
import type Player from "video.js/dist/types/player";
|
|
|
|
|
import "./plugins/register";
|
|
|
|
|
import { type EngineStrategy, type PlaybackEngine } from "./engine-selector";
|
|
|
|
|
export interface VideoPlayerRuntimeSource {
|
|
|
|
|
src: string;
|
|
|
|
|
type?: string;
|
|
|
|
|
}
|
|
|
|
|
export type VideoPlayerRuntimePreload = "auto" | "metadata" | "none" | "visibility";
|
|
|
|
|
export type VideoPlayerRuntimeEventMap = {
|
|
|
|
|
ready: {
|
|
|
|
|
engine: PlaybackEngine;
|
|
|
|
|
source: VideoPlayerRuntimeSource;
|
|
|
|
|
player: VideoPlayerRuntimePlayer;
|
|
|
|
|
};
|
|
|
|
|
enginechange: {
|
|
|
|
|
previous: PlaybackEngine | null;
|
|
|
|
|
next: PlaybackEngine;
|
|
|
|
|
source: VideoPlayerRuntimeSource;
|
|
|
|
|
};
|
|
|
|
|
sourcechange: {
|
|
|
|
|
previous: VideoPlayerRuntimeSource;
|
|
|
|
|
next: VideoPlayerRuntimeSource;
|
|
|
|
|
engine: PlaybackEngine;
|
|
|
|
|
};
|
|
|
|
|
manifestloaded: {
|
|
|
|
|
engine: PlaybackEngine;
|
|
|
|
|
duration?: number;
|
|
|
|
|
live?: boolean;
|
|
|
|
|
};
|
|
|
|
|
duration: {
|
|
|
|
|
duration: number;
|
|
|
|
|
};
|
|
|
|
|
playstart: {
|
|
|
|
|
engine: PlaybackEngine;
|
|
|
|
|
};
|
|
|
|
|
error: {
|
|
|
|
|
scope: "runtime" | "player" | "hls";
|
|
|
|
|
error: unknown;
|
|
|
|
|
fatal?: boolean;
|
|
|
|
|
};
|
|
|
|
|
dispose: Record<string, never>;
|
|
|
|
|
};
|
|
|
|
|
export type VideoPlayerRuntimePlayer = Player & {
|
|
|
|
|
hlsInstance?: Hls | null;
|
|
|
|
|
liveTracker?: {
|
|
|
|
|
isLive_: boolean;
|
|
|
|
|
atLiveEdge?: () => boolean;
|
|
|
|
|
startTracking: () => void;
|
|
|
|
|
trigger: (event: string) => void;
|
|
|
|
|
};
|
|
|
|
|
settingsMenu?: () => void;
|
|
|
|
|
bigPlayPauseButton?: () => void;
|
|
|
|
|
skipButtons?: (options: {
|
|
|
|
|
skip: number;
|
|
|
|
|
}) => void;
|
|
|
|
|
subscribeToSegmentChange: (callback: (segment: unknown) => void) => void;
|
|
|
|
|
subscribeToDuration: (callback: (duration: number) => void) => void;
|
|
|
|
|
subscribeToPlayStart: (callback: () => void) => void;
|
|
|
|
|
subscribeToPlayStarted: (callback: () => void) => void;
|
|
|
|
|
subscribeToManifestLoaded: (callback: () => void) => void;
|
|
|
|
|
mediaduration: () => number | undefined;
|
|
|
|
|
};
|
|
|
|
|
interface VideoPlayerRuntimeOptions {
|
|
|
|
|
source: VideoPlayerRuntimeSource;
|
|
|
|
|
strategy: EngineStrategy;
|
|
|
|
|
preload: VideoPlayerRuntimePreload;
|
|
|
|
|
autoplay: boolean;
|
|
|
|
|
controls: boolean;
|
|
|
|
|
responsive: boolean;
|
|
|
|
|
aspectRatio?: string;
|
|
|
|
|
fluid: boolean;
|
|
|
|
|
muted: boolean;
|
|
|
|
|
poster?: string;
|
|
|
|
|
preferHQ: boolean;
|
|
|
|
|
debug: boolean;
|
|
|
|
|
initialTime: number;
|
|
|
|
|
isIOS?: boolean;
|
|
|
|
|
isMobile?: boolean;
|
|
|
|
|
full: boolean;
|
|
|
|
|
withRewind: boolean;
|
|
|
|
|
skipSeconds: number;
|
|
|
|
|
classNames: string[];
|
|
|
|
|
onPlayerReady?: (player: VideoPlayerRuntimePlayer, state: VideoPlayerRuntimeState) => void;
|
|
|
|
|
}
|
|
|
|
|
export interface VideoPlayerRuntimeInitOptions extends Partial<Omit<VideoPlayerRuntimeOptions, "source">> {
|
|
|
|
|
container: HTMLElement;
|
|
|
|
|
source: VideoPlayerRuntimeSource;
|
|
|
|
|
}
|
|
|
|
|
export interface VideoPlayerRuntimeUpdateOptions extends Partial<Omit<VideoPlayerRuntimeOptions, "source">> {
|
|
|
|
|
source?: VideoPlayerRuntimeSource;
|
|
|
|
|
}
|
|
|
|
|
export interface VideoPlayerRuntimeState {
|
|
|
|
|
initialized: boolean;
|
|
|
|
|
engine: PlaybackEngine | null;
|
|
|
|
|
source: VideoPlayerRuntimeSource | null;
|
|
|
|
|
}
|
|
|
|
|
export type VideoPlayerRuntimeUnsubscribe = () => void;
|
|
|
|
|
export declare class VideoPlayerRuntime {
|
|
|
|
|
private containerRef;
|
|
|
|
|
private videoRef;
|
|
|
|
|
private playerRef;
|
|
|
|
|
private hlsRef;
|
|
|
|
|
private options;
|
|
|
|
|
private currentEngine;
|
|
|
|
|
private currentSource;
|
|
|
|
|
private vhsAuthTokenRef;
|
2026-03-11 13:47:47 +03:00
|
|
|
private hlsAuthTokenRef;
|
|
|
|
|
private hlsTokenResolvePromise;
|
2026-02-27 09:50:13 +03:00
|
|
|
private vhsRequestCleanupRef;
|
|
|
|
|
private visibilityObserverRef;
|
|
|
|
|
private originalPlayRef;
|
|
|
|
|
private hlsLoaded;
|
|
|
|
|
private eventListeners;
|
|
|
|
|
init(options: VideoPlayerRuntimeInitOptions): Promise<VideoPlayerRuntimeState>;
|
|
|
|
|
update(options: VideoPlayerRuntimeUpdateOptions): Promise<VideoPlayerRuntimeState>;
|
|
|
|
|
on<K extends keyof VideoPlayerRuntimeEventMap>(event: K, handler: (payload: VideoPlayerRuntimeEventMap[K]) => void): VideoPlayerRuntimeUnsubscribe;
|
|
|
|
|
dispose(): void;
|
|
|
|
|
getState(): VideoPlayerRuntimeState;
|
|
|
|
|
getPlayer(): VideoPlayerRuntimePlayer | null;
|
2026-03-11 13:47:47 +03:00
|
|
|
private ensureHlsAuthToken;
|
|
|
|
|
private refreshHlsAuthTokenInBackground;
|
2026-02-27 09:50:13 +03:00
|
|
|
private emit;
|
|
|
|
|
private tryPlay;
|
|
|
|
|
private resolveEngine;
|
|
|
|
|
private createVideoElement;
|
|
|
|
|
private createPlayer;
|
|
|
|
|
private syncPoster;
|
|
|
|
|
private syncPlayerDisplayOptions;
|
|
|
|
|
private attachCompatibilityApi;
|
|
|
|
|
private attachDurationAndPlayStartHooks;
|
|
|
|
|
private loadCurrentSource;
|
|
|
|
|
private buildHlsConfig;
|
|
|
|
|
private loadHlsSource;
|
|
|
|
|
private loadVideoJsSource;
|
|
|
|
|
private resetDeferredHlsLoading;
|
|
|
|
|
private ensureVhsAuthInterceptor;
|
|
|
|
|
private teardownHls;
|
|
|
|
|
}
|
|
|
|
|
export {};
|
|
|
|
|
//# sourceMappingURL=player-runtime.d.ts.map
|