HTML Audio/Video DOM videoTracks attribute

Example

Get the number of available video tracks:

myVid=document.getElementById("video1");
alert(myVid.videoTracks.length);

Try it yourself

Definition and usage

The videoTracks attribute returns a VideoTrackList object.

The VideoTrackList object represents the available video tracks of the video.

The VideoTrack object represents each available video track.

Browser support

No mainstream browser supports the videoTracks attribute.

syntax

video.videoTracks

return value

type description
TextTrackList object

represents the available video tracks of the video.

VideoTrackList object:

  • videoTracks.length - the number of available video tracks in the video
  • videoTracks.getTrackById(id) - Get VideoTrack object by id
  • videoTracks[index] - Get VideoTrack object by index
  • videoTracks.selectedIndex - Get the index of the current VideoTrack object

Note:The index of the first available VideoTrack object is 0.

TextTrack Object

Represents a video track.

Properties of VideoTrack Object:

  • id - Get the id of the video track
  • kind - Get the type of the video track (can be "alternative", "captions", "main", "sign", "subtitles", "commentary", or "" (empty string))
  • label - Get the label of the video track
  • language - Get the language of the video track
  • selected - Get or set whether the video track is active (true|false)