ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
25 lines (24 loc) • 1.3 kB
TypeScript
export interface PlayerTrackConfig {
kind?: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
src: string;
srclang: string;
label: string;
default?: boolean;
}
/** Rebuilds the `<track>` children from scratch — cheap, and avoids diffing. */
export declare function applyTracksToVideo(video: HTMLVideoElement, tracks: PlayerTrackConfig[]): void;
/**
* Takes `video.textTracks` (a `TextTrackList`) rather than the `<video>` itself —
* keeps this testable with a plain array of track-like objects, since jsdom
* doesn't implement the TextTrack API at all (`video.textTracks.length` stays 0
* no matter how many `<track>` children exist).
*
* `lang` is a track's `srclang`, or `'off'` to hide every track. Cue rendering
* itself is entirely native — this only toggles which TextTrack the browser
* is allowed to render.
*/
export declare function setActiveSubtitleLanguage(tracks: Iterable<TextTrack>, lang: string): void;
export declare function getActiveSubtitleLanguage(tracks: Iterable<TextTrack>): string;
/** Global, not per-src — a viewer's language preference should follow them across videos. */
export declare function loadPreferredSubtitleLanguage(): string;
export declare function savePreferredSubtitleLanguage(lang: string): void;