10.07.2015 Views

Building the User Interface by Using HTML5: Text, Graphics ... - server

Building the User Interface by Using HTML5: Text, Graphics ... - server

Building the User Interface by Using HTML5: Text, Graphics ... - server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

48 | Lesson 2The three primary types of audio files supported <strong>by</strong> popular browsers are OGG, MP3, andWAV. However, not every browser supports every audio file format, at least not today. For <strong>the</strong>most part, MP3 is <strong>the</strong> best choice for multiple browser compatibility.To help ensure your audio plays on <strong>the</strong> majority of browsers and devices, use <strong>the</strong> sourceattribute to include multiple formats in your markup. This example shows <strong>the</strong> same audiofile available in two formats:LICENSED PRODUCT NOT FOR RESALEYou can find a lot of free audio files, which are also royalty and copyright free, athttp://flashkit.com. This is a good resource for learners, and for developers who may needa sound effect for a project. Ano<strong>the</strong>r source is <strong>the</strong> Public Domain Sherpa Web site athttp://www.publicdomainsherpa.com/public-domain-recordings.html. You can also makeyour own recordings using your computer and recording software. Windows 7 includes <strong>the</strong>Sound Recorder, which lets you save audio files in WAV format.Figure 2-19<strong>HTML5</strong> default audio controlsin a Web browserWORK WITH THE AUDIO ELEMENTGET READY. To work with <strong>the</strong> <strong>HTML5</strong> audio element, perform <strong>the</strong> following steps:1. Locate an audio clip.2. In your editing tool, create an HTML file with <strong>the</strong> following markup. Substitute <strong>the</strong>appropriate file name for your audio clip.Audio Test3. Save your file as L2-audio.html and view it in a browser. You should see somethingsimilar to Figure 2-19. Because we didn’t include <strong>the</strong> autoplay attribute in thisexample, you need to click <strong>the</strong> Play button to start <strong>the</strong> audio clip.

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

Saved successfully!

Ooh no, something went wrong!