label
Summary
Returns the label of the given track, if known, or the empty string otherwise.
Property of apis/audio-video/AudioTrackapis/audio-video/AudioTrack
Syntax
Note: This property is read-only.
var result = AudioTrack.label;
Return Value
Returns an object of type StringString
Examples
<video id="video1" controls >
<source src="http://ie.microsoft.com/testdrive/Videos/BehindIE9ModernWebStandards/Video.mp4">
<track id="entrack" label="English subtitles" kind="captions" src="entrack.vtt" srclang="en" default>
<track id="sptrack" label="Spanish subtitles" kind="captions" src="estrack.vtt" srclang="es">
<track id="detrack" label="German subtitles" kind="captions" src="detrack.vtt" srclang="de">
</video>
<br />
<button id="gettracks" >View text tracks</button>
<div id="display"></div>
<script>
document.getElementById("gettracks").addEventListener("click", function () {
var display = document.getElementById("display");
display.innerHTML = "";
var mytracks = document.getElementById("video1").textTracks; // get the textTrackList
for (var i = 0; i < mytracks.length; i++) {
display.innerHTML += (mytracks[i].label + "<br/>"); //append track label to inner text of <div>
}
}, false);
</script>
Related specifications
- W3C HTML5 Specification
- W3C Editor’s Draft
Attributions
Microsoft Developer Network: Windows Internet Explorer API reference Article