<pclass="legacydocsnote">This documentation is for an outdated version of Video.js. See <ahref="https://docs.videojs.com/tutorial-audio-tracks.html">documentation for the current release</a>.
<p>Audio Tracks are a function of HTML5 video for providing alternative audio track selections to the user, so that a track other than the main track can be played. Video.js makes audio tracks work across all browsers. There are currently five types of tracks:</p>
<ul>
<li><strong>Alternative</strong>: alternative audio for the main video track</li>
<li><strong>Descriptions</strong>: descriptions of what is happening in the video track</li>
<li><strong>Main</strong>: the main audio track for this video</li>
<li><strong>Translation</strong>: a translation of the main audio track</li>
<li><strong>Commentary</strong>: commentary on the video, usually the director of the content talking about design choices</li>
<li>It is currently impossible to add AudioTracks in a non-programtic way</li>
<li>Literal switching of AudioTracks for playback is not handled by video.js and must be handled by something else. video.js only stores the track representation</li>
</ul>
<h2id="adding-to-video-js">Adding to Video.js</h2>
<blockquote>
<p>Right now adding audio tracks in the HTML is unsupported. Audio Tracks must be added programatically.</p>
</blockquote>
<p>You must add audio tracks <ahref="#api">programatically</a> for the time being.</p>
<h2id="attributes">Attributes</h2>
<p>Audio Track propertites and settings</p>
<h3id="kind">kind</h3>
<p>One of the five track types listed above. Kind defaults to empty string if no kind is included, or an invalid kind is used.</p>
<h3id="label">label</h3>
<p>The label for the track that will be show to the user, for example in a menu that list the different languages available for audio tracks.</p>
<h3id="language">language</h3>
<p>The two-letter code (valid BCP 47 language tag) for the language of the audio track, for example "en" for English. A list of language codes is <ahref="languages.md#language-codes">available here</a>.</p>
<h3id="enabled">enabled</h3>
<p>If this track should be playing or not. In video.js we only allow one track to be enabled at a time. so if you enable more than one the last one to be enabled will end up being the only one.</p>
<h2id="interacting-with-audio-tracks">Interacting with Audio Tracks</h2>
<h3id="doing-something-when-a-track-becomes-enabled">Doing something when a track becomes enabled</h3>
<p>When a new track is enabled (other than the main track) an event is fired on the <code>AudioTrackList</code> called <code>change</code> you can listen to that event and do something with it.
Here's an example:</p>
<pre><codeclass="lang-js">// get the current players AudioTrackList object