HTML Audio / Video DOM videoTracks Thuộc tính

❮ Tham chiếu DOM Audio / Video HTML

Thí dụ

Nhận số lượng bản nhạc video có sẵn:

var vid = document.getElementById("myVideo");
alert(vid.videoTracks.length);

Định nghĩa và Cách sử dụng

Thuộc tính videoTracks trả về một đối tượng VideoTrackList.

Đối tượng VideoTrackList đại diện cho các đoạn video có sẵn cho video.

Mỗi đoạn video có sẵn được đại diện bởi một Đối tượng VideoTrack.


Hỗ trợ trình duyệt

Property
videoTracks Not supported Not supported Not supported Not supported Not supported

Cú pháp

video.videoTracks

Giá trị trả lại

Type Description
VideoTrackList Object Represents the available video tracks for the video.

VideoTrackList Object:

  • videoTracks.length - get the number of video tracks available 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 first available VideoTrack object is index 0

VideoTrack Object Represents a video track.

VideoTrack Object Properties:

  • 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 if the track is active (true|false)

❮ Tham chiếu DOM Audio / Video HTML