language property
Gets the BCP47 language tag of an AudioTrack or TextTrack if available, or an empty string if not.
This property is read-only.
![]() ![]() |
Syntax
HRESULT get_language( [out] DOMString **sLanguage );
Property values
Type: DOMString
Standards information
Remarks
The language tag is not displayed to the user for text tracks. The following example uses the label attribute for text to display (such as "English") in the player's track list.
<video id="video1" controls autoplay loop>
<source src="video.mp4" type="video/mp4">
<track id="enTrack" src="entrack.vtt" label="English" kind="subtitles" srclang="en" default>
<track id="esTrack" src="estrack.vtt" label="Spanish" kind="subtitles" srclang="es">
<track id="deTrack" src="detrack.vtt" label="German" kind="subtitles" srclang="de">
HTML5 video not supported
</video>
The audio track label is set when the video is created, or you can use the label property to set it.
Examples
The following example gets the number of audioTracks associated with a video object, and displays the IHTMLElement::language and enabled status of each.
<script type="text/javascript"> function getLanguages() { oAudioTracks = document.getElementById("video1").audioTracks; document.getElementById("display").innerHTML = ""; for (var i = 0; i < oAudioTracks.length; i++) { document.getElementById("display").innerHTML += "Track " + i + " Language: " + oAudioTracks[i].language + " is " + ((oAudioTracks[i].enabled == true) ? "enabled" : "not enabled")+"<br/>"; } } </script> </head> <body> <video id="video1" src="multi-lang-movie.mp4" controls >HTML5 video not supported </video> <br /> <button onclick="getLanguages();">Get language status</button> <div id="display"></div> </body> </html>
Build date: 11/12/2012

