22.06.2015 Views

o_19octlt3v29m1ul81r9513q81i4ra.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

278 Chapter 15<br />

Not surprisingly, you use the width and height attributes to set the width and the height<br />

of the video display area on the page, as shown in the following example:<br />

<br />

The controls attribute determines whether a default set of playback controls should<br />

be visible within the browser. This can be helpful and I recommend using it. In fact, if<br />

you don’t use the controls attribute, the visitor has no way to replay the video without<br />

reloading the entire page. How annoying! Here’s an example of the controls attribute:<br />

<br />

The preload attribute tells the browser to begin downloading the video immediately<br />

when the element is encountered. If the video is the central theme of the page, and it’s<br />

likely that all (or most) visitors will want to watch the video, then it’s a good idea to use<br />

the preload option. However, if the video element is a small part of the page and visitors<br />

aren’t likely to watch it, then preloading the video is just a waste of bandwidth. Here’s the<br />

preload attribute in action:<br />

<br />

The loop attribute tells the browser to restart the video immediately when it’s finished<br />

playing, as shown here:<br />

<br />

Finally, the autoplay attribute makes the video automatically play when the page is<br />

loaded. For most purposes, this is generally a bad idea from a usability standpoint. Most<br />

users will want control over the video; they’ll play it when their attention is focused<br />

and they’re ready to consume the video element. And even with the autoplay attribute<br />

enabled, your visitors might have that option disabled in their browsers. For that reason,<br />

along with the usability problem, I recommend not using the autoplay attribute with one<br />

notable exception: if you don’t include the controls attribute, then you need to include<br />

autoplay; otherwise, the video won’t play and visitors will have no way to start it. Here’s<br />

an example of the autoplay attribute:<br />

<br />

Putting it together, a real-world video element looks like this:<br />

<br />

The preceding examples all work well if your visitors have a browser such as Firefox 3.5 or<br />

later or Opera 10.5 or later. However, what if a visitor has Internet Explorer? In that case,<br />

you’ll need to encode the video so that it can be played in Internet Explorer. The

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!