HTML Audio/Video DOMvideoTracksProperty

HTML audio/video 标签参考手册HTML Audio/Video DOM Reference Manual

Examples

Get the number of available video tracks:

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

Try it Yourself »

Definition and Usage

The videoTracks property returns a VideoTrackList object.

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

Each available video track is represented by a VideoTrack object.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All mainstream browsers do not support the videoTracks property.


Syntax

video.videoTracks

Return Value

Type Description
VideoTrackList object Represents the available video tracks of a video.

VideoTrackList object:

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

Note:The index of the first available VideoTrack objectindexis 0.

VideoTrack object Represents a video track.

Properties of the 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)


HTML audio/video 标签参考手册HTML Audio/Video DOM Reference Manual Other Extensions