HTML | DOM Audio textTracks Property

The HTML DOM Audio textTracks Property is used for returning a TextTrackList object.
The TextTrackList object represents the available text tracks for the audio. Every available text track is represented by a TextTrack Object.

Syntax:

audioObject.textTracks 

Return Value: It returns a TextTrackList Object Which represents the available text tracks for the the audio.
TextioTrackList Object are:

  • length:It is used to get the number of text tracks available in the audio
  • [index]: It is used to get TextTrack object by index

Examples:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title>HTML DOM Audio textTracks Property
  
</title
    <style
        h1 { 
            color: green; 
        
          
        h2 { 
            font-family: Impact; 
        
          
        body { 
            text-align: center; 
        
    </style
</head
  
<body
  
    <h1>GeeksforGeeks</h1
    <h2>HTML DOM Audio textTracks Property
  
</h2
  
    <audio id="track" controls> 
        <source src="bells.ogg" type="audio/ogg"
        <source src="bells.mp3" type="audio/mpeg"
      <track src="demo_sub.vtt">
  
    Your browser does not support the audio element. 
    </audio
  
    <p>Double-click the "Access Audio" button 
    to get the duration of the audio, in seconds.</p
  
    <button onclick="access()">Access Audio</button
  
    <p id="test"></p
  
    <script
        function access() { 
              
            // Accessing audio element duration. 
            var m = document.getElementById( 
            "track").textTracks.length;; 
            document.getElementById("test").innerHTML = m; 
        
    </script
  
</body
  
</html

chevron_right


Output:
Before clicking the button:

After clicking the button:

Supported Browsers: The browser supported by DOM Audio textTracks Property
are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.