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.

HTML5 A vocabulary and associated APIs for HTML and XHTMLInternet Explorer 10



HRESULT get_language(
  [out] DOMString **sLanguage

Property values

Type: DOMString

The BCP47 language tag of the track. For example "en" for English or "fr" for French.

Standards information


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="" 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

The audio track label is set when the video is created, or you can use the label property to set it.


The following example gets the number of audioTracks associated with a video object, and displays the IHTMLElement::language and enabled status of each.

<!DOCTYPE html >
<html >
  <title>AudioTracks example</title>

    <h1>AudioTrack languages example</h1>
    <video id="video1" src="multi-lang-movie.mp4" controls >HTML5 video not supported </video>
    <br />
    <button id="mybutton">Get language status</button>
    <div id="display"></div>
      document.getElementById("mybutton").addEventListener("click", function () {
        var oAudioTracks = document.getElementById("video1").audioTracks;
        var display = document.getElementById("display");
        display.innerHTML = "";
        for (var i = 0; i < oAudioTracks.length; i++) {
          display.innerHTML += "Track " + i;
          display.innerHTML += " Language: " + oAudioTracks[i].language;
          display.innerHTML += " is   " + ((oAudioTracks[i].enabled == true) ? "enabled" : "not enabled") + "<br/>";



Community Additions

© 2015 Microsoft