Chapter 24. Inserting Audio

Although sound is not appropriate for every website, it's definitely an online option — and essential to certain types of sites. Just as with images and video, there is a vast range of formats for audio, but only a few are widely used. In this lesson, you learn which formats are the most compatible with the Web, the simplest approach to bringing music to a site, how to integrate an audio plug-in, and how to play audio natively with HTML5.

USING WEB-COMPATIBLE AUDIO

To play an audio file on the Web, the sound must be recorded in a digital format. Uncompressed audio formats, such as the Audio Interchange File Format (AIFF) developed by Apple or Waveform Audio File Format (WAV) created by Microsoft and IBM, were popular in the early history of the Web. Although still seen on some websites, most web designers have switched to faster-loading, compressed audio formats like MP3.

The MP3 — short for MPEG Audio Layer 3 — format features high-quality digital audio files with excellent compression. MP3 has become the standard for downloadable music. Like all formats prior to HTML5, MP3 requires a plug-in, but support is widespread. MP3 files can be played in the QuickTime Player, RealPlayer, Windows Media Player, and a whole range of standalone players that work as browser helper applications. Basic MP3 files must be completely downloaded before they begin to play.

Another approach is streaming audio, which plays as it downloads. RealAudio, developed by RealNetworks, ...

Get HTML5 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.