Playing Dolby Audio

Because not every system has Dolby Audio, we want to first make sure that Dolby Audio plays in our setup.

We now play a Dolby mediatype; this will work on some devices and not on others.

Figure 1. Playback of Dolby Digital Plus using the HTML5 audio element. Listen to the audio; you should hear a voice saying You're listening to Dolby Digital Plus audio.
<h1>Web App: Playing Dolby Audio</h1>
<p>Expect to hear audio. NOTE: This is an audio only application.</p>

<audio id="mediaContainer">This device does not support the &lt;audio&gt; element</audio>

<script>
    let mediaContainer = document.getElementById('mediaContainer'); // HTMLMediaElement
    let content_src    = "media/v01/mp4/audio_en_ec-3_1.mp4";       // Dolby Digital Plus Audio in MP4 Container
    
    mediaContainer.controls = true;
    mediaContainer.src      = content_src;
    mediaContainer.autoplay = true;
</script>
  1. we are leaving off the header, for sake of clarity.
  2. The audio element makes use of the HTML5 audio element which is a simple interface to play audio. There is also a video element which plays both audio and video, but we are trying to keep this example simple.
  3. We are playing an entire mp4 file containing Dolby Digital Plus Audio.
  4. The file name contains the identifier ec-3. You will see this and similar identifiers everywhere in the tutorial. ec-3 is standardized in ETSI TS 102 366; Dolby audio builds on the standardized Dolby Digital Plus technology.
  5. we are using the mediaContainer.controls element. This provides a default set of control elements, including play controls and a volume control.

If you heard the audio: congratulations, your environment supports Dolby Digital Plus and you just wrote your first web application for playback of Dolby mediatypes. Read on for how to make it more robust.

If you did not hear anything, it may be that your machine does not support playback. In the next lesson, we will learn how to programmatically query a machine for whether it supports the mediatype.