Selecting by language and for accessibility

When everything is said and done, there may still be more than one experience to pick from. Let's find that which best matches the user's preferences.

We now understand how to determine the subset of AdaptationSets that is supported on the system. If the assets are provided in more than one language, and if there are versions for people with special accessibility needs, it is possible that you are still left with several AdaptationSets from which to choose. How do you find that which best matches the user's preferences?

The most obvious ranking is by language, but accessibility features are gaining importance as well. The following manifest file provides three audio AdaptationSets, one in English language, one in Spanish language and a third in English language with "Audio Descriptions":

Figure 1. A manifest file with three audio adaptation sets
<?xml version="1.0" ?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT5.00S" mediaPresentationDuration="PT30.040S" type="static">
  <!-- Created with Bento4 mp4-dash.py, VERSION=2.0.0-637 -->
  <Period>
    <!-- Video -->
    <AdaptationSet id="1" mimeType="video/mp4" segmentAlignment="true" startWithSAP="1" maxWidth="1920" maxHeight="1080">
      <Label lang="en">Video</Label>
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
      <SegmentTemplate timescale="1000" duration="5000" initialization="$RepresentationID$/init.mp4" media="$RepresentationID$/seg-$Number$.m4s" startNumber="1"/>
      <Representation id="video/avc1" codecs="avc1.4D4029" width="1920" height="1080" scanType="progressive" frameRate="25" bandwidth="638625"/>
    </AdaptationSet>
    <!-- Audio -->
    <AdaptationSet id="3" mimeType="audio/mp4" startWithSAP="1" segmentAlignment="true" lang="en" selectionPriority="98">
      <Label lang="en">Dolby Digital Plus - 5.1 - English</Label>
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
      <SegmentTemplate timescale="1000" duration="5000" initialization="$RepresentationID$/init.mp4" media="$RepresentationID$/seg-$Number$.m4s" startNumber="1"/>
      <Representation id="audio/en/ec-3/1" codecs="ec-3" bandwidth="385179" audioSamplingRate="48000">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:mpegB:cicp:ChannelConfiguration" value="6"/>
      </Representation>
    </AdaptationSet>
    <AdaptationSet id="7" mimeType="audio/mp4" startWithSAP="1" segmentAlignment="true" lang="es" selectionPriority="96">
      <Label lang="en">Dolby Digital Plus - 5.1 - Spanish</Label>
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
      <SegmentTemplate timescale="1000" duration="5000" initialization="$RepresentationID$/init.mp4" media="$RepresentationID$/seg-$Number$.m4s" startNumber="1"/>
      <Representation id="audio/es/ec-3" codecs="ec-3" bandwidth="385179" audioSamplingRate="48000">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:mpegB:cicp:ChannelConfiguration" value="6"/>
      </Representation>
    </AdaptationSet>
    <AdaptationSet id="8" mimeType="audio/mp4" startWithSAP="1" segmentAlignment="true" lang="en" selectionPriority="95">
      <Label lang="en">Dolby Digital Plus - Stereo - English Audio Description</Label>
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="alternate"/>
      <Accessibility schemeIdUri="urn:mpeg:dash:role:2011" value="description"/>
      <SegmentTemplate timescale="1000" duration="5000" initialization="$RepresentationID$/init.mp4" media="$RepresentationID$/seg-$Number$.m4s" startNumber="1"/>
      <Representation id="audio/en/ec-3/3" codecs="ec-3" bandwidth="97179" audioSamplingRate="48000">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:mpegB:cicp:ChannelConfiguration" value="2"/>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>

Let's assume the user prefers to listen to a Spanish version of the content, preferably with the accessibility option of "AudioDescription". The manifest lists a Spanish version, and an "AudioDescription" version, but not both combined. Language will take precedence and dash.js is expected to play the Spanish language option.

To tell dash.js to use only those audio AdaptationSets in a Manifest that match a provided language tag and accessibility preference, the setInitialMediaSettingsFor() method can be used.

Figure 2. Filtering for language and accessibility features
var videoElement =  document.querySelector('video');
var url = "media/v01/dash/multiLangAD.mpd";
var player = dashjs.MediaPlayer().create();

player.initialize();

// register a callback to display all available audio tracks
let tt = TrackTable(document.getElementById('divTracks'), true);
tt.registerCb(player);

// tell dash.js to select spanish language, preferrably with audio description  
player.setInitialMediaSettingsFor('audio', {lang: 'es', accessibility: 'description'});

player.setAutoPlay(true);
player.attachView(videoElement);
player.attachSource(url);