HTML and CSS Reference
In-Depth Information
chapter eleven
Adding Video and Audio
THE WEBSITE YOU have been building for Joe's Pizza Co. looks pretty good so far, but it would look even better
if it included a video. In this chapter, you update the About page, adding a short video with some custom playback
controls that you build yourself. When the video is in place, you learn how you can make video and audio content
more accessible by adding subtitles to your multimedia content.
Until recently, embedding video and audio within a web page required the use of a third-party plug-in, such as Adobe
Flash or Microsoft Silverlight. The result was a fragmented ecosystem of plug-ins that users had to install, manage,
and upgrade, often confusing less tech-savvy individuals. This approach also meant that developers had less control
over their video content.
The capability to create custom playback controls or special effects required the use of proprietary software such as
Adobe Flash Professional. Even when developers did take the leap and purchase this considerably expensive software,
they still had to learn a whole new programming language, ActionScript, in order to achieve what they desired.
Fortunately, HTML5 introduces a new way of embedding video and audio into web pages. Using the new <video>
and <audio> elements, developers can now add multimedia content to their websites as easily as they can add im-
ages or text. Hurray!
Converting Video and Audio Files
Before you can start adding video and audio to your web pages, you first need to make sure browsers will be able to
play your multimedia files. In this section, you learn about the various video and audio formats that are natively sup-
ported by modern web browsers. ( Natively means there is no need for a plug-in.) You also create the video files you
will use in the Joe's Pizza Co. website.
Video File Formats
Three main video formats are used for HTML5 video: WebM, MP4, and OGV. Unfortunately, the browser
vendors each had their own opinions on which format should become the standard; therefore, no one format is suppor-
ted by all modern web browsers. This means you must convert your video file into all three formats to ensure that
everyone can see it. I cover how to detect whether a browser supports a certain video format later in this chapter.
Table 11-1 shows browser support for the three main video formats. Notice that by using the WebM and MP4 formats,
you can cover all modern web browsers. MP4 files, however, are usually quite large, so it is often useful to provide an
OGV file, too, because OGV files are much smaller and take less time to download.
Search WWH ::




Custom Search