The TextTrack interface—part of the API for handling WebVTT (text tracks on media presentations)—describes and controls the text track associated with a particular <track> element.
Properties
This interface also inherits properties from EventTarget.
TextTrack.activeCuesRead only- A
TextTrackCueListobject listing the currently active set of text track cues. Track cues are active if the current playback position of the media is between the cues' start and end times. Thus, for displayed cues such as captions or subtitles, the active cues are currently being displayed. TextTrack.cuesRead only- A
TextTrackCueListwhich contains all of the track's cues. TextTrack.idRead only- A
DOMStringwhich identifies the track, if it has one. If it doesn't have an ID, then this value is an empty string (""). If theTextTrackis associated with a<track>element, then the track's ID matches the element's ID. TextTrack.inBandMetadataTrackDispatchTypeRead only- Returns a
DOMStringwhich indicates the track's in-band metadata track dispatch type. needs details TextTrack.kindRead only- Returns a
DOMStringindicating what kind of text track theTextTrackdescribes. The value must be one of those in the TextTrackKind enum. TextTrack.labelRead only- A human-readable
DOMStringwhich contains the text track's label, if one is present; otherwise, this is an empty string (""), in which case a custom label may need to be generated by your code using other attributes of the track, if the track's label needs to be exposed to the user. TextTrack.languageRead only- A
DOMStringwhich specifies the text language in which the text track's contents is written. The value must adhere to the format specified in the Tags for Identifying Languages (BCP 47) document from the IETF, just like the HTMLlangattribute. For example, this can be"en-US"for United States English or"pt-BR"for Brazilian Portuguese. TextTrack.mode- A
DOMStringspecifying the track's current mode. Changing this property's value changes the track's current mode to match. Permitted values are listed under Text track mode constants. The default isdisabled, unless the<track>element'sdefaultBoolean attribute is specified, in which case the default mode isstarted.
Events
cuechange- Fired when cues are entered and exited. A given text cue appears when the cue is entered and disappears when the cue is exited.
Also available via theoncuechangeproperty.
Methods
This interface also inherits methods from EventTarget.
TextTrack.addCue()- Adds a cue (specified as a
TextTrackCueobject to the track's list of cues. TextTrack.removeCue()- Removes a cue (specified as a
TextTrackCueobject from the track's list of cues.
Example
tbd
Specifications
| Specification | Status | Comment |
|---|---|---|
| HTML Living Standard The definition of 'TextTrack' in that specification. |
Living Standard |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
TextTrack | Chrome Full support 18 | Edge Full support 12 | Firefox
Full support
31
| IE Full support 10 | Opera Full support 15 | Safari Full support 6 | WebView Android Full support 4.4 | Chrome Android Full support 18 | Firefox Android Full support 31 | Opera Android No support No | Safari iOS Full support 7 | Samsung Internet Android Full support 1.0 |
activeCues | Chrome Full support 18 | Edge Full support 12 | Firefox
Full support
31
| IE Full support 10 | Opera Full support 15 | Safari Full support 6 | WebView Android Full support 4.4 | Chrome Android Full support 18 | Firefox Android Full support 31 | Opera Android No support No | Safari iOS Full support 7 | Samsung Internet Android Full support 1.0 |
addCue | Chrome Full support 18 | Edge Full support 12 | Firefox Full support 31 | IE Full support 10 | Opera Full support 15 | Safari Full support 6 | WebView Android Full support 4.4 | Chrome Android Full support 18 | Firefox Android Full support 31 | Opera Android No support No | Safari iOS Full support 7 | Samsung Internet Android Full support 1.0 |
cuechange event | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 31 | IE ? | Opera ? | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 31 | Opera Android No support No | Safari iOS ? | Samsung Internet Android Full support Yes |
cues | Chrome Full support 18 | Edge Full support 12 | Firefox
Full support
31
| IE Full support 10 | Opera Full support 15 | Safari Full support 6 | WebView Android Full support 4.4 | Chrome Android Full support 18 | Firefox Android Full support 31 | Opera Android No support No | Safari iOS Full support 7 | Samsung Internet Android Full support 1.0 |
id | Chrome Full support 18 | Edge Full support 12 | Firefox Full support 31 | IE Full support 10 | Opera Full support 15 | Safari Full support 6 | WebView Android Full support 4.4 | Chrome Android Full support 18 | Firefox Android Full support 31 | Opera Android No support No | Safari iOS Full support 7 | Samsung Internet Android Full support 1.0 |
inBandMetadataTrackDispatchType | Chrome Full support 18 | Edge Full support 12 | Firefox Full support 31 | IE Full support 10 | Opera Full support 15 | Safari Full support 6 | WebView Android Full support 4.4 | Chrome Android Full support 18 | Firefox Android Full support 31 | Opera Android No support No | Safari iOS Full support 7 | Samsung Internet Android Full support 1.0 |
kind | Chrome Full support 18 | Edge Full support 12 | Firefox Full support 31 | IE Full support 10 | Opera Full support 15 | Safari Full support 6 | WebView Android Full support 4.4 | Chrome Android Full support 18 | Firefox Android Full support 31 | Opera Android No support No | Safari iOS Full support 7 | Samsung Internet Android Full support 1.0 |
label | Chrome Full support 18 | Edge Full support 12 | Firefox Full support 31 | IE Full support 10 | Opera Full support 15 | Safari Full support 6 | WebView Android Full support 4.4 | Chrome Android Full support 18 | Firefox Android Full support 31 | Opera Android No support No | Safari iOS Full support 7 | Samsung Internet Android Full support 1.0 |
language | Chrome Full support 18 | Edge Full support 12 | Firefox Full support 31 | IE Full support 10 | Opera Full support 15 | Safari Full support 6 | WebView Android Full support 4.4 | Chrome Android Full support 18 | Firefox Android Full support 31 | Opera Android No support No | Safari iOS Full support 7 | Samsung Internet Android Full support 1.0 |
mode | Chrome Full support 18 | Edge Full support 12 | Firefox
Full support
31
| IE Full support 10 | Opera Full support 15 | Safari Full support 6 | WebView Android Full support 4.4 | Chrome Android Full support 18 | Firefox Android Full support 31 | Opera Android No support No | Safari iOS Full support 7 | Samsung Internet Android Full support 1.0 |
oncuechange | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 31 | IE ? | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 31 | Opera Android No support No | Safari iOS ? | Samsung Internet Android Full support Yes |
removeCue | Chrome Full support 18 | Edge Full support 12 | Firefox Full support 31 | IE Full support 10 | Opera Full support 15 | Safari Full support 6 | WebView Android Full support 4.4 | Chrome Android Full support 18 | Firefox Android Full support 31 | Opera Android No support No | Safari iOS Full support 7 | Samsung Internet Android Full support 1.0 |
sourceBuffer | Chrome No support No | Edge No support No | Firefox ? | IE ? | Opera ? | Safari Full support Yes | WebView Android No support No | Chrome Android No support No | Firefox Android ? | Opera Android No support No | Safari iOS ? | Samsung Internet Android No support No |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- See implementation notes.
- See implementation notes.
