The VideoTrack
interface represents a single video track from a <video>
element. The most common use for accessing a VideoTrack
object is to toggle its selected
property in order to make it the active video track for its <video>
element.
Properties
selected
- A Boolean value which controls whether or not the video track is active. Only a single video track can be active at any given time, so setting this property to
true
for one track while another track is active will make that other track inactive. id
Read only- A
DOMString
which uniquely identifies the track within the media. This ID can be used to locate a specific track within a video track list by callingVideoTrackList.getTrackById()
. The ID can also be used as the fragment part of the URL if the media supports seeking by media fragment per the Media Fragments URI specification. kind
Read only- A
DOMString
specifying the category into which the track falls. For example, the main video track would have akind
of"main"
. label
Read only- A
DOMString
providing a human-readable label for the track. For example, a track whosekind
is"sign"
might have alabel
of"A sign-language interpretation"
. This string is empty if no label is provided. language
Read only- A
DOMString
specifying the video track's primary language, or an empty string if unknown. The language is specified as a BCP 47 (RFC 5646) language code, such as"en-US"
or"pt-BR"
. sourceBuffer
Read only- The
SourceBuffer
that created the track. Returns null if the track was not created by aSourceBuffer
or theSourceBuffer
has been removed from theMediaSource.sourceBuffers
attribute of its parent media source.
Usage notes
To get a VideoTrack
for a given media element, use the element's videoTracks
property, which returns a VideoTrackList
object from which you can get the individual tracks contained in the media:
var el = document.querySelector("video");
var tracks = el.videoTracks;
You can then access the media's individual tracks using either array syntax or functions such as forEach()
.
This first example gets the first video track on the media:
var firstTrack = tracks[0];
The next example scans through all of the media's video tracks, activating the first video track that is in the user's preferred language (taken from a variable userLanguage
).
for (var i = 0; i < tracks.length; i++) {
if (tracks[i].language === userLanguage) {
tracks[i].selected = true;
break;
}
});
The language
is in standard (RFC 5646) format. For US English, this would be "en-US"
, for example.
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living StandardThe definition of 'VideoTrack' in that specification. | Living Standard |
Browser compatibility
The compatibility table in 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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
VideoTrack
|
Chrome Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Edge Full support 79 Full support 79 Disabled' From version 79: this feature is behind the |
Firefox Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
IE
Full support 10 |
Opera Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari
Full support 6.1 |
WebView Android
No support No |
Chrome Android Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Firefox Android Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
Opera Android Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari iOS
Full support 7 |
Samsung Internet Android
No support No |
id
|
Chrome Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Edge Full support 79 Full support 79 Disabled' From version 79: this feature is behind the |
Firefox Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
IE
Full support 10 |
Opera Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari
Full support 6.1 |
WebView Android
No support No |
Chrome Android Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Firefox Android Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
Opera Android Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari iOS
Full support 7 |
Samsung Internet Android
No support No |
kind
|
Chrome Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Edge Full support 79 Full support 79 Disabled' From version 79: this feature is behind the |
Firefox Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
IE
Full support 10 |
Opera Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari
Full support 6.1 |
WebView Android
No support No |
Chrome Android Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Firefox Android Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
Opera Android Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari iOS
Full support 7 |
Samsung Internet Android
No support No |
label
|
Chrome Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Edge Full support 79 Full support 79 Disabled' From version 79: this feature is behind the |
Firefox Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
IE
Full support 10 |
Opera Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari
Full support 6.1 |
WebView Android
No support No |
Chrome Android Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Firefox Android Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
Opera Android Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari iOS
Full support 7 |
Samsung Internet Android
No support No |
language
|
Chrome Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Edge Full support 79 Full support 79 Disabled' From version 79: this feature is behind the |
Firefox Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
IE
Full support 10 |
Opera Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari
Full support 6.1 |
WebView Android
No support No |
Chrome Android Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Firefox Android Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
Opera Android Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari iOS
Full support 7 |
Samsung Internet Android
No support No |
selected
|
Chrome Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Edge Full support 79 Full support 79 Disabled' From version 79: this feature is behind the |
Firefox Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
IE
Full support 10 |
Opera Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari
Full support 6.1 |
WebView Android
No support No |
Chrome Android Full support 37 Full support 37 Disabled' From version 37: this feature is behind the |
Firefox Android Full support 33 Full support 33 Disabled' From version 33: this feature is behind the |
Opera Android Full support 24 Full support 24 Disabled' From version 24: this feature is behind the |
Safari iOS
Full support 7 |
Samsung Internet Android
No support No |
sourceBuffer
|
Chrome Full support 51 Full support 51 Disabled' From version 51: this feature is behind the |
Edge Full support 79 Full support 79 Disabled' From version 79: this feature is behind the |
Firefox
No support No |
IE
No support No |
Opera Full support 38 Full support 38 Disabled' From version 38: this feature is behind the |
Safari
Full support 6.1 |
WebView Android
No support No |
Chrome Android Full support 51 Full support 51 Disabled' From version 51: this feature is behind the |
Firefox Android
No support No |
Opera Android Full support 41 Full support 41 Disabled' From version 41: this feature is behind the |
Safari iOS
Full support 7 |
Samsung Internet Android
No support No |
Legend
- Full support
- Full support
- No support
- No support
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
VideoTrack by Mozilla Contributors is licensed under CC-BY-SA 2.5.