HTML TIPS | |
|
|
HTML AND SOUND | |
Adding sound or background music to your website is easier than you
think. It's just the ongoing war between Netscape and Microsoft that makes things a bit tricky. For example, Microsoft's Internet Explorer supports the <BGSOUND> (background sound) tag but Netscape does not. So, if you're a dedicated Gatesian, and don't care who arrives at your site using the Netscape browser (or any other browser, for that matter), just use the <BGSOUND> tag. However, if you are more interested in accomodating everyone who views your page, then use the <EMBED> tag, supported by most browsers, including Netscape 3.0 and Internet Explorer 3.0. <BGSOUND> TAG Two attributes make up the <BGSOUND> tag: SRC (source) and LOOP. The SRC attribute calls up the sound file and LOOP specifies how many times the audio clip will play. For instance, to play a sound file called hal.wav on a website viewed with Internet Explorer, just upload the sound file to your server as raw data and include the following code in your HTML document: <BGSOUND SRC="hal.wav" LOOP=6> In this instance, the sound file hal.wav will play 6 times in a row. You can make the sound file play as many times as you want by changing the value of the LOOP. If you want the sound file to repeat for as long as the viewer stays on your page (and keep in mind that this can be annoying), use LOOP=INFINITE. Your HTML will read as follows: <BGSOUND SRC="hal.wav" LOOP=INFINITE> Using the BGSOUND tag, sound files can be uploaded and played in WAV, AU, or MIDI format. As with images, remember to keep sound file size to a minimum. A 60k sound file will take about one minute to download via a 14.4 modem, and only after it has loaded, will it begin to play. <EMBED> TAG The EMBED command works on both Netscape Navigator 3.0 and Microsoft Internet Explorer 3.0. Although the tag works a lot like Explorer's BGSOUND, it includes several different attributes. To embed a sound file (let's use hal.wav again as an example) and have it play in the background, upload the sound file to your server as raw data and include the following tag in your HTML document: <EMBED SRC="hal.wav" HIDDEN=TRUE AUTOSTART=TRUE LOOP=TRUE> EMBED SRC tells the browser where to find the sound file. HIDDEN=TRUE tells the browser to load the sound file but not to display a sound control panel. If you use the attribute HIDDEN=FALSE, a sound player control panel with play, stop, pause, and volume control buttons will be displayed. Keep in mind, however, that if you choose to display this sound control panel, you must also specify a HEIGHT and WIDTH attribute for the CONSOLE (WIDTH=144 HEIGHT=74 is suggested). Your tag would then look like the following: <EMBED SRC="hal.wav" HIDDEN=FALSE AUTOSTART=FALSE LOOP=FALSE WIDTH=144 HEIGHT=74 CONTROLS=CONSOLE> AUTOSTART=TRUE specifies that the sound file will automatically start to play as soon as the file is loaded. If you change the attribute to AUTOSTART=FALSE, the audio will not start to play until the user instructs it to do so. LOOP=TRUE specifies that the sound file will play an infinite number of times. With LOOP=FALSE, the sound file will play only once. LOOP=4 (or any number you choose) will cause the sound file to play 4 times. Sound files can be uploaded and played in WAV, AIFF, AU, and MIDI format. In addition, you can use the EMBED tag to play QuickTime movies, AVI files (under Windows 95 and NT), and VRML files. |