HTML: The Definitive Guide

Previous Chapter 5 Next
 

5.4 Background Audio

There is one other form of inline multimedia generally available to Web surfers--audio. Most browsers treat audio multimedia as separate documents, downloaded and displayed by special helper applications or applets. Internet Explorer, on the other hand, contains a built-in sound decoder and supports a special HTML tag that lets you integrate an audio file with your document that plays in the background as a soundtrack for your page.

We applaud the developers of Internet Explorer for providing a mechanism for more cleanly integrating audio into HTML documents. And the possibilites with audio are very enticing. But at the same time, we caution authors that the special tags and attributes for audio don't work with other browsers, and whether or not this is the method that the majority of browsers will eventually support is not at all assured. So, beware.[3]

[3] There is an alternative way of providing background audio for Netscape, which we describe in Chapter 11, Netscape Dynamic Documents.

The <bgsound> Tag

Use the <bgsound> tag to play a soundtrack in the background. This tag is for Internet Explorer documents only. All other browsers ignore the tag. It downloads and plays an audio file when the host HTML document is first downloaded by the user and displayed in their browser. The background sound file also will replay whenever the user refreshes the browser display.

The src attribute

The src attribute is required for the <bgsound> tag. Its value references the URL for the related sound file. For example, when the Internet Explorer user first downloads an HTML document containing the tag:

<bgsound src="audio/welcome.wav">

they will hear the welcome.wav audio file--perhaps an inviting message--play once through their computer's sound system.

Currently, Internet Explorer can handle three different sound formats files: wav, the native format for PCs; au, the native format for most UNIX workstations; and MIDI, a universal music-encoding scheme (also see Table 5.1, which appears in 5.7.1).

The loop attribute

Like Internet inline movies, the loop attribute for the browser's <bgsound> tag lets you replay a background soundtrack for a certain number of times, or over and over again forever--at least until the user moves on to another page or quits the browser.

The value of the loop attribute is the integer number of times to replay the audio file, or infinite, which makes the soundtrack repeat endlessly.

For example:

<bgsound src="audio/tadum.wav" loop=10>

repeats the ta-dum soundtrack ten times, whereas:

<bgsound src="audio/noise.wav" loop=infinite>

continuously plays the noise soundtrack.


Previous Home Next
Document Colors and Background Images Book Index Animated Text
 


Banner.Novgorod.Ru