label
Summary
Returns the text track label, if there is one, or the empty string otherwise (indicating that a custom label probably needs to be generated from the other attributes of the object if the object is exposed to the user).
Property of apis/audio-video/TextTrackapis/audio-video/TextTrack
Syntax
Note: This property is read-only.
var result = TextTrack.label;
Return Value
Returns an object of type StringString
Examples
<!DOCTYPE HTML>
<html>
<head>
<title>Get track example</title>
</head>
<body>
<h1>Get track example</h1>
<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>
</video>
<p>
<button id="mybutton">Show label</button>
</p>
<div style="display:block; overflow:auto; height:200px; width:650px;" id="display"></div>
<script>
document.getElementById("mybutton").addEventListener("click", function () {
var myTrack = document.getElementById("entrack").track; // get text track from track element
var myLabel = myTrack.label; // get label
document.getElementById("display").innerHTML = myLabel;
}, false);
</script>
</body>
</html>
Related specifications
- W3C HTML5 Specification
- W3C Editor’s Draft
Attributions
Microsoft Developer Network: Windows Internet Explorer API reference Article