UNPKG

libpgs

Version:

Renderer for graphical subtitles (PGS) in the browser.

67 lines (66 loc) 2.17 kB
import { PgsRendererOptions } from "./pgsRendererOptions"; /** * Renders PGS subtitle on-top of a video element using a canvas element. This also handles timestamp updates if a * video element is provided. */ export declare class PgsRenderer { /** * Creates and starts a PGS subtitle render with the given option. * @param options The PGS renderer options. */ constructor(options: PgsRendererOptions); /** * Creates the PGS renderer implementation for the given option. * @param options The PGS renderer options. */ private createPgsRenderer; private implementation; /** * Loads the subtitle file from the given url. * @param url The url to the PGS file. */ loadFromUrl(url: string): void; /** * Loads the subtitle file from the given buffer. * @param buffer The PGS data. */ loadFromBuffer(buffer: ArrayBuffer): void; /** * Renders the subtitle for the given timestamp. * @param time The timestamp in seconds. */ renderAtTimestamp(time: number): void; private readonly video?; private $timeOffset; /** * Gets the video-to-subtitle time offset in seconds. */ get timeOffset(): number; /** * Sets the video-to-subtitle time offset and re-renders the current subtitle if needed. * @param timeOffset The new time offset in seconds. */ set timeOffset(timeOffset: number); private registerVideoEvents; private unregisterVideoEvents; private onTimeUpdate; private renderAtVideoTimestamp; private readonly canvas; private readonly canvasOwner; private createCanvasElement; private destroyCanvasElement; private $aspectRatio; /** * Gets the aspect ratio mode of the canvas. */ get aspectRatio(): 'contain' | 'cover' | 'fill'; /** * Sets the aspect ratio mode of the canvas. This should match the `object-fit` property of the video. * @param aspectMode The aspect mode. */ set aspectRatio(aspectMode: 'contain' | 'cover' | 'fill'); /** * Destroys the subtitle canvas and removes event listeners. */ dispose(): void; }