TextTracks
Summary
A media element can have a group of associated text tracks, known as the media element’s "list of text tracks".
Properties
- activeCues
- Returns the text track cues from the text track list of cues that are currently active (i.e. that start before the current playback position and end after it), as a TextTrackCueList object.
- cues
- Returns the text track list of cues, as a TextTrackCueList object.
- inBandMetadataTrackDispatchType
- Returns the text track in-band metadata track dispatch type string. This is a string extracted from the media resource specifically for in-band metadata tracks, to enable such tracks to be dispatched to different scripts in the document.
- kind
- Returns the text track kind string.
- label
- Returns the text track label, if there is one, or the empty string otherwise (indicating that a custom label probably needs to be generated from the other attributes of the object if the object is exposed to the user).
- language
- Returns the text track language string.
- mode
- The text track mode, represented by a string from the following list. "disabled": The text track disabled mode. "hidden": The text track hidden mode. "showing": The text track showing mode.
Methods
- addCue
- Adds the given cue to textTrack’s text track list of cues.
- removeCue
- Removes the given cue from textTrack’s text track list of cues.
Events
No events.
Notes
The track object contains the collection of TextTrackCues (times and text) that are contained in the file that the track element represents.
WEBVTT
TextTrackCues within a TextTrack can be defined within a WebVTT file which is defined as an 8-bit Unicode Transformation Format (UTF-8) format text files that look like the following.
WEBVTT
00:00:01.878 --> 00:00:05.334
Good day everyone, my name is John Smith
00:00:08.608 --> 00:00:15.296
This video will teach you how to
build a sand castle on any beach
The file starts with the tag “WEBVTT” as the first line, followed by a line feed. The timing cues are in the format "HH:MM:SS.sss". The start and end time cues are separated by a space, two hyphens and a greater-than sign ( --> ), and another space. The timing cues are on a line by themselves followed by a line feed. Immediately following the cue is the caption text. Text captions can be one or more lines. The only restriction is that there must be no blank lines between lines of text. The MIME type is "text/vtt".
Related specifications
- W3C HTML5 Specification
- W3C Editor’s Draft