Skip to main content

Function: attachCaptionTrack()

attachCaptionTrack(video, vtt, options): CaptionTrackHandle

Defined in: src/a11y/captions.ts:141

Attach a WebVTT caption string to a <video> as a <track kind="captions">.

The VTT is wrapped in a blob and exposed through an object URL. The returned handle's remove() detaches the track and revokes the URL.

Parameters​

video​

HTMLVideoElement

vtt​

string

options​

CaptionTrackOptions = {}

Returns​

CaptionTrackHandle

A handle, or null when there is no DOM (Node / SSR) or the video cannot take a child. The feature never throws off the browser.