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.
This interface also inherits properties from EventTarget
.
TextTrack.activeCues
Read only
TextTrackCueList
object 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.TextTrack.cues
Read only
TextTrackCueList
which contains all of the track's cues.TextTrack.id
Read only
DOMString
which identifies the track, if it has one. If it doesn't have an ID, then this value is an empty string (""
). If the TextTrack
is associated with a <track>
element, then the track's ID matches the element's ID.TextTrack.inBandMetadataTrackDispatchType
Read only
DOMString
which indicates the track's in-band metadata track dispatch type. needs details
TextTrack.kind
Read only
DOMString
indicating what kind of text track the TextTrack
describes. The value must be one of those in the TextTrackKind enum.TextTrack.label
Read only
DOMString
which 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.language
Read only
DOMString
which 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 HTML lang
attribute. For example, this can be "en-US"
for United States English or "pt-BR"
for Brazilian Portuguese.TextTrack.mode
DOMString
specifying 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.TextTrack.oncuechange
EventHandler
specifying a function to be called when a cuechange
event occurs. Handling these events lets you know when cues are entered and exited. A given text cue appears when the cue is entered and disappears when the cue is exited.This interface also inherits methods from EventTarget
.
TextTrack.addCue()
TextTrackCue
object to the track's list of cues.TextTrack.removeCue()
TextTrackCue
object from the track's list of cues.tbd
Specification | Status | Comment |
---|---|---|
WebVTT: The Web Video Text Tracks Format | Candidate Recommendation |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 18 | 12 | 31
|
10 | 15 | 6 |
activeCues |
18 | 12 | 31 | 10 | 15 | 6 |
cues |
18 | 12 | 31 | 10 | 15 | 6 |
id |
18 | 12 | 31 | 10 | 15 | 6 |
inBandMetadataTrackDispatchType |
18 | 12 | 31 | 10 | 15 | 6 |
kind |
18 | 12 | 31 | 10 | 15 | 6 |
label |
18 | 12 | 31 | 10 | 15 | 6 |
language |
18 | 12 | 31 | 10 | 15 | 6 |
mode |
18 | 12 | 31
|
10 | 15 | 6 |
oncuechange |
Yes | 12 | 31 | ? | ? | ? |
addCue |
18 | 12 | 31 | 10 | 15 | 6 |
removeCue |
18 | 12 | 31 | 10 | 15 | 6 |
sourceBuffer |
? | ? | ? | ? | ? | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 4.4 | 18 | No | 31 | No | 7.1 | Yes |
activeCues |
4.4 | 18 | No | 31 | No | 7.1 | Yes |
cues |
4.4 | 18 | No | 31 | No | 7.1 | Yes |
id |
4.4 | 18 | No | 31 | No | 7.1 | Yes |
inBandMetadataTrackDispatchType |
4.4 | 18 | No | 31 | No | 7.1 | Yes |
kind |
4.4 | 18 | No | 31 | No | 7.1 | Yes |
label |
4.4 | 18 | No | 31 | No | 7.1 | Yes |
language |
4.4 | 18 | No | 31 | No | 7.1 | Yes |
mode |
4.4 | 18 | No | 31 | No | 7.1 | Yes |
oncuechange |
Yes | Yes | No | 31 | No | ? | Yes |
addCue |
4.4 | 18 | No | 31 | No | 7.1 | Yes |
removeCue |
4.4 | 18 | No | 31 | No | 7.1 | Yes |
sourceBuffer |
? | ? | ? | ? | ? | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/TextTrack