UNPKG

ranui

Version:

A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.

71 lines (70 loc) 3.08 kB
import type { PlaybackSnapshot } from './playback'; import type { PlayerContextState, PlayerRuntimeState } from './state'; export interface PlayerChromeRefs { player: HTMLDivElement; playerBtn: HTMLDivElement; playerController: HTMLDivElement; playControllerBottomVolume: HTMLDivElement; playControllerBottomPip: HTMLDivElement; playControllerBottomRemote: HTMLDivElement; gestureFlash: HTMLElement; } export type PlayerChromeRuntimeState = Pick<PlayerRuntimeState<PlaybackSnapshot>, 'isBuffering' | 'controllerBarTimeId'>; export interface PlayerChromeDeps { refs: PlayerChromeRefs; state: PlayerChromeRuntimeState; ctx: Pick<PlayerContextState, 'currentState' | 'fullScreen' | 'playbackRate' | 'volume' | 'duration' | 'currentTime'>; getVideo: () => HTMLVideoElement | undefined; isDebug: () => boolean; play: () => void; pause: () => void; setCurrentTime: (n: number) => number; setPlaybackRate: (n: number) => number; setVolume: (n: number) => number; safePlay: (showLoading: boolean) => void; change: (name: string, value: unknown) => void; updateCurrentProgress: () => void; /** * Self-forwarding entries for this module's own `resize`/`customRequestFullscreen`/ * `customExitFullscreen` — `openFullScreen`/`SpaceKeyDown` call these through the * RanPlayer wrapper (`this.resize()` etc.) instead of the local closures below, so a * `vi.spyOn(player, 'resize')` set up after construction still intercepts them (a bare * local reference would forever point at the pre-spy original). */ resize: () => void; customRequestFullscreen: () => Promise<void>; customExitFullscreen: () => Promise<void>; getVolumeMemo: () => number | undefined; setVolumeMemo: (n: number) => void; rememberPosition: () => boolean; getSrc: () => string; getCurrentTime: () => number; } export interface PlayerChromeHandlers { setLoadingState: (loading: boolean) => void; showControllerBar: (e?: MouseEvent) => void; customRequestFullscreen: () => Promise<void>; customExitFullscreen: () => Promise<void>; openFullScreen: () => void; dispatchClickPlayerContainerAction: (e: Event) => void; dispatchClickPlayerBtnAction: (e: Event) => void; SpaceKeyDown: (e: KeyboardEvent) => void; onPlayBtnKeydown: (e: KeyboardEvent) => void; onFullScreenKeydown: (e: KeyboardEvent) => void; changeVolumeProgress: (e: Event) => void; changePlayerVolume: () => void; changeSpeed: (e: Event) => void; syncPipButtonVisibility: () => void; togglePip: () => void; syncRemoteButtonVisibility: () => void; showRemotePlaybackPicker: () => void; resize: () => void; onVisibilityChange: () => void; fullScreenChange: () => void; } /** * Control-bar chrome: play/pause dispatch, keyboard shortcuts, volume, speed, * fullscreen, Picture-in-Picture, the auto-hiding controller bar, and the * buffering class. */ export declare function createChromeHandlers(deps: PlayerChromeDeps): PlayerChromeHandlers;