Skip to Content
HTML5 for Publishers
book

HTML5 for Publishers

by Sanders Kleinfeld
October 2011
Intermediate to advanced
56 pages
3h 2m
English
O'Reilly Media, Inc.
Content preview from HTML5 for Publishers

Chapter 3. <audio>/<video> for Publishers

One of the most exciting features of HTML5 is that it offers native support for audio and video content. On the Web, this means that reliance on browser plugins in order to facilitate display of multimedia content is becoming a thing of the past. On the ereader side, HTML5 and EPUB 3 open the door to embedding this same multimedia content directly within an ebook. Let’s take a quick look at HTML5’s new <audio> and <video> elements.

A Two-Minute Introduction to the <audio> and <video> Elements

The standard HTML5 <audio> element looks like this:

<audio id="new_slang">
<source src="new_slang.wav" type="audio/wav"/>
<source src="new_slang.mp3" type="audio/mp3"/>
<source src="new_slang.ogg" type="audio/ogg"/>
<em>(Sorry, &lt;audio&gt; element not supported in your
  browser/ereader, so you will not be able to listen to
  this song.)</em>
</audio>

The <audio> element serves as a container, which holds a series of <source> elements that reference your audio files (src attribute) in whichever formats you have available (type attribute). If you only have one format available, you can abbreviate the markup as follows:

<audio id="new_slang" src="new_slang.wav">No song for you!</audio>

However, current best practice is to provide audio in multiple formats—usually WAV, MP3, and Ogg—in order to ensure compatibility across the range of HTML5 audio–compliant browsers and ereaders (see HTML5 Audio/Video Compatibility in the Browser and Ereaders).

The <audio> element ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

HTML5 Hacks

HTML5 Hacks

Jesse Cravens, Jeff Burtoft
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 9781449320065Supplemental ContentErrata Page