Text tracks
Subtitles, captions, and chapter track state for the player store
Manages subtitles, captions, chapters, and thumbnail tracks.
API Reference
State
| Property | Type | Details |
|---|---|---|
chaptersCues | MediaTextCue[] | |
| ||
thumbnailCues | MediaTextCue[] | |
| ||
thumbnailTrackSrc | null | string | |
| ||
textTrackList | MediaTextTrack<TextTrackKind>[] | |
| ||
subtitlesShowing | boolean | |
| ||
Actions
| Action | Type | Details |
|---|---|---|
toggleSubtitles | (forceShow: boolean) => boolean | |
| ||
Selector
Pass selectTextTracks to usePlayer to subscribe to text track state. Returns undefined if the text tracks feature is not configured.
import { selectTextTracks, usePlayer } from '@videojs/react';
function CaptionsButton() {
const tracks = usePlayer(selectTextTracks);
if (!tracks) return null;
return (
<button onClick={() => tracks.toggleSubtitles()}>
{tracks.subtitlesShowing ? 'Hide captions' : 'Show captions'}
</button>
);
}