The HTMLTrackElement
interface represents an HTML <track>
element within the DOM. This element can be used as a child of either <audio>
or <video>
to specify a text track containing information such as closed captions or subtitles.
The HTMLTrackElement
interface represents an HTML <track>
element within the DOM. This element can be used as a child of either <audio>
or <video>
to specify a text track containing information such as closed captions or subtitles.
Inherits properties from its parent, HTMLElement
.
HTMLTrackElement.kind
A string that reflects the kind
HTML attribute, indicating how the text track is meant to be used. Possible values are: subtitles
, captions
, descriptions
, chapters
, or metadata
.
HTMLTrackElement.src
A string that reflects the src
HTML attribute, indicating the address of the text track data.
HTMLTrackElement.srclang
A string that reflects the srclang
HTML attribute, indicating the language of the text track data.
HTMLTrackElement.label
A string that reflects the label
HTML attribute, indicating a user-readable title for the track.
HTMLTrackElement.default
A boolean value reflecting the default
attribute, indicating that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate.
HTMLTrackElement.readyState
Read only
Returns an unsigned short
that show the readiness state of the track:
Constant | Value | Description |
---|---|---|
NONE | 0 | Indicates that the text track's cues have not been obtained. |
LOADING | 1 | Indicates that the text track is loading and there have been no fatal errors encountered so far. Further cues might still be added to the track by the parser. |
LOADED | 2 | Indicates that the text track has been loaded with no fatal errors. |
ERROR | 3 | Indicates that the text track was enabled, but when the user agent attempted to obtain it, this failed in some way. Some or all of the cues are likely missing and will not be obtained. |
HTMLTrackElement.track
Read only
Returns TextTrack
is the track element's text track data.
No specific method; inherits methods from its parent, HTMLElement
.
The following events may be fired on a <track>
element, in addition to any that may be fired at its parent, HTMLElement
.
The WebVTT or TTML data describing the actual cues for the text track isn't loaded if the track's mode
is initially in the disabled
state. If you need to be able to perform any processing on the track after the <track>
is set up, you should instead ensure that the track's mode
is either hidden
(if you don't want it to start out being presented to the user) or showing
(to initially display the track). You can then change the mode as desired later.
Specification |
---|
HTML Standard # htmltrackelement |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
HTMLTrackElement |
23 | 12 | 31Before Firefox 50, text tracks would only load if the<track> element is in a document. |
10 | 12 | 6 | 4.4 | 25 | 31Before Firefox 50, text tracks would only load if the<track> element is in a document. |
12 | 6 | 1.5 |
cuechange_event |
3223Theoncuechange event handler property is not supported. |
14 | 68 | No | 1915Theoncuechange event handler property is not supported. |
106Theoncuechange event handler property is not supported. |
≤37Theoncuechange event handler property is not supported. |
3225Theoncuechange event handler property is not supported. |
68 | 1914Theoncuechange event handler property is not supported. |
106Theoncuechange event handler property is not supported. |
2.01.5Theoncuechange event handler property is not supported. |
default |
23 | 12 | 31 | 10 | 12 | 6 | 4.4 | 25 | 31 | 12 | 6 | 1.5 |
kind |
23 | 12 | 31 | 10 | 12 | 6 | 4.4 | 25 | 31 | 12 | 6 | 1.5 |
label |
23 | 12 | 31 | 10 | 12 | 6 | 4.4 | 25 | 31 | 12 | 6 | 1.5 |
readyState |
23 | 12 | 31 | 10 | 12 | 6 | 4.4 | 25 | 31 | 12 | 6 | 1.5 |
src |
23 | 12 | 31Before Firefox 50, setting thesrc property did not work properly. |
10 | 12 | 6 | 4.4 | 25 | 31Before Firefox 50, setting thesrc property did not work properly. |
12 | 6 | 1.5 |
srclang |
23 | 12 | 31 | 10 | 12 | 6 | 4.4 | 25 | 31 | 12 | 6 | 1.5 |
track |
23 | 12 | 31 | 10 | 12 | 6 | 4.4 | 25 | 31 | 12 | 6 | 1.5 |
<track>
.
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement