English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Das read-only-Attribut textTracks des HTMLMediaElement-Objekts gibt eine TextTrackList-Instanz zurück, die alle TextTrack-Objekte auflistet, die die Textspuren des Medienelements darstellen, in der Reihenfolge, in der sie in der Textspur-Liste stehen.
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 10Opera, Chrome and Safari 6 Supports the textTracks attribute.
Note:Internet Explorer 9 And earlier versions do not support the textTracks attribute.
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:
|