English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The read-only textTracks property on the HTMLMediaElement object returns a TextTrackList object, which lists all TextTrack objects representing the text tracks of the media element, in the same order as the text track list.
HTML Audio/Video DOM Reference Manual
Get the number of available text tracks:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/Video textTracks attribute usage-Basic tutorial(oldtoolbag.com)</<title> </<head> <body> <button onclick="getTextTracks()" type="button">Get the number of available text tracks</button> <br> <video id="video1" controls="controls"> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> <track src="demo_sub.vtt"> Your browser does not support HTML5 video tag. </video> <script> myVid=document.getElementById("video1"); function getTextTracks() { alert(myVid.textTracks.length); } </script> </body> </html>Test to see ‹/›
The textTracks property returns a TextTrackList object.
The TextTrackList object represents audio/The available text tracks of the video.
Each available text track is represented by a TextTrack object.
IEFirefoxOperaChromeSafari
Internet Explorer 10、Opera、Chrome and Safari 6 Supports the textTracks property.
Note:Internet Explorer 9 And earlier versions do not support the textTracks property.
audio|video.textTracks
Type | Description |
---|---|
TextTrackList object | Represents audio/The available text tracks of the video. TextioTrackList object:
Note:Index of the first available text track index is 0. |
TextTrack object | Represents a text track. Properties of the TextTrack object:
|