Sams Teach Yourself HTML 4 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Tell Us What You Think!
- Put Your HTML Page Online Today
- I. Your First Web Page
- Hour 1. Understanding HTML and XML
- Hour 2. Create a Web Page Right Now
- Hour 3. Linking to Other Web Pages
- Hour 4. Publishing Your HTML Pages
- II. Web Page Text
- Hour 5. Text Alignment and Lists
- Hour 6. Text Formatting and Font Control
- Hour 7. Email Links and Links Within a Page
- Hour 8. Creating HTML Forms
- III. Web Page Graphics
- Hour 9. Creating Your Own Web Page Graphics
- Hour 10. Putting Graphics on a Web Page
- Hour 11. Custom Backgrounds and Colors
- Hour 12. Creating Animated Graphics
- IV. Web Page Design
- Hour 13. Page Design and Layout
- Hour 14. Graphical Links and Imagemaps
- Hour 15. Advanced Layout with Tables
- Hour 16. Using Style Sheets
- V. Dynamic Web Pages
- Hour 17. Embedding Multimedia in Web Pages
- Hour 18. Interactive Pages with Applets and ActiveX
- Hour 19. Web Page Scripting for Non-Programmers
- Hour 20. Setting Pages in Motion with Dynamic HTML
- VI. Building a Web Site
- Hour 21. Multipage Layout with Frames
- Hour 22. Organizing and Managing a Web Site
- Hour 23. Helping People Find Your Web Pages
- Hour 24. Planning for the Future of HTML
- VII. Appendixes
- A. Readers' Most Frequently Asked Questions
- B. HTML Learning Resources on the Internet
- C. Complete HTML 4 Quick Reference
- D. HTML Character Entities
Embedding Sound in a Web Page
Over the past few years, Microsoft and Netscape have offered various conflicting solutions to the problem of how to put multimedia on a Web page. Some of these, such as Microsoft's proprietary extensions to the <img> tag, are now completely obsolete.
One non-standard tag has endured, however; Netscape's <embed /> tag is now actually more compatible with both Netscape and Microsoft browsers than the official HTML 4 <object> tag, which was supposed to replace it.
The <embed /> tag enables you to place any type of file directly into your Web page. For the media to appear on the Web page, however, every user must have a plug-in or OLE-compatible helper application that recognizes the incoming data type and knows what to do with it. The media players that come bundled with Internet Explorer and Netscape Navigator can handle most common media types, including WAV, AU, MPEG, MID, EPS, VRML, and many more. Many other plug-ins are also available from other companies to handle almost any type of media file.
The following line of HTML would embed a sound clip named hello.wav and display the playback controls at the current position on the page, as long as visitors to the page have a WAV-compatible plug-in or helper app.
<embed src="hello.wav" />
Notice that, like the <img> tag, <embed /> requires a src attribute to indicate the address of the embedded media file. Also like <img>, the <embed /> tag can take align, width, and height attributes. The src, width, height, and align attributes are interpreted by the browser just as they would be for a still image. However, the actual display of the data is handled by whichever plug-in or helper application each user may have installed. In the case of sound files, the sound is played and some controls are usually displayed. Which controls actually appear depend on which plug-in or helper application each individual user has installed, so you, as a Web page author, can't know ahead of time exactly what someone will see.
The <embed /> tag also enables you to set any number of optional parameters, which are specific to the plug-in or player program. For instance, the page in Figure 17.1 includes the following:
Figure 17.1 The <embed /> tag embeds multimedia files directly into a Web page in Netscape Navigator and Microsoft Internet Explorer.
<embed src="atune.mid" width="1" height="1" autostart="true" loop="true" hidden="true" />
This causes the music file atune.mid to play whenever the page is displayed. As you can see in Figure 17.2, this has no visual effect on the page whatsoever. (Since this book doesn't have any speakers, you can't hear the auditory effect unless you pull the page up online at http://24hourHTMLcafe.com/hour17/.)
Figure 17.2 If you were looking at this page (from Figure 17.1) on a computer with a sound card and speakers, you would hear the atune.mid file playing.
autostart, loop, and hidden are not standard attributes of the <embed /> tag, so the browser simply hands them over to the plug-in program to interpret. autostart="true", loop="true", and hidden="true" are specific to the LiveAudio plug-in that comes built-in to Netscape Navigator 3 and 4. (They tell it to automatically play the sound as soon as it loads, to play it over again each time it finishes, and not to display any controls on the Web page.) If a user has a different AVI plug-in, or no plug-in at all for handling MIDI (Musical Instrument Digital Interface) files, these attributes will do nothing at all. Refer to the Web pages of each plug-in developer for information on the commands that its plug-in will accept as attributes in the <embed /> tag.
If a suitable plug-in can't be found for an <embed /> tag, the Windows 95/98 versions of both Netscape Navigator and Microsoft Internet Explorer may embed an OLE-compliant application (such as the Media Player application that comes with Windows) to play the media file. Therefore, the sound will play successfully in both Netscape Navigator and Microsoft Internet Explorer.
Embedding Video in a Web Page | Next Section

Account Sign In
View your cart