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 audio. TextioTrackList Object is:
- 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: In this example, we will see the use of DOM Audio textTracks Property.
HTML
<!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.
let m = document.getElementById(
"track").textTracks.length;;
document.getElementById("test").innerHTML = m;
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers: The browser supported by DOM Audio textTracks Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
16 Jun, 2023
Like Article
Save Article