HOME Calendar Join / Renew PC Alamode About Us HELP Sponsors
Reviews Columns Features Archives Other  


 The Lazy Webmaster

Your site is alive
with the sound of music
November 2003

Susan Ives

Susan Ives is a past-president and past-webmaster of Alamo PC.


I do not like sites that automatically play music. Most people don’t. They blare with no warning, often in inappropriate situations like the office when the boss is within listening range. They often have no volume control, or worse, reset the user’s volume. The quickest way to turn off the music is to exit the site, so it drives people away. Some people will get error messages when they don’t have the proper sound configuration, or may get sinister warnings that they are about to download a program that could contain tainted code. When the user moves onto another page the music stops – probably just at the passage he or she likes best. I have been tempted to insert background music but I always come to my senses. The theory is sweet, the implementation goes sour.

But you want to try it anyway, don’t you?

This is a code that will work in both Internet Explorer and Netscape Navigator:

    <embed src="sample.wav"
    autostart="true"
    hidden="false"
    loop="false">
    <noembed> <bgsound src="sample.wav" loop="1"> </noembed></embed>

It will work for a WAV or MIDI file, plus the less-common .au and .aiff. I find that MP3 files word as well. There are a few parameters. Where the code says sample.wav, replace this with your own sound file, and remember to upload the sound file to the server. “Hidden=false” displays small sound controls. It’s kinder to give the user control over the volume. “true” would hide the sound controls. Both “loop=false” and “loop=1” mean that the file will play (loop) only once. On the Lazy Webmaster Website, I have an example of an embedded sound.

One of the problems with embedded sound is that it stops when you go to another page. My friend Patrick Collier taught me a work-around for this. Design your site using frames, and have a tiny frame that carries over to every page. The code for the frameset page would look something like this:

    <HTML>
    <HEAD>
    <title>title</title>
    </HEAD>
    <FRAMESET COLS="*,1">
       <FRAME SRC="maincontent.html" SCROLLING="AUTO"

    NORESIZE MARGINHEIGHT="0" MARGINWIDTH="0"
    NAME="main">
       <FRAME SRC="midi.html" SCROLLING="NO"

    NORESIZE MARGINHEIGHT="0" MARGINWIDTH="0"
    NAME="midi">
    </FRAMESET>
    </HTML>

This will give you a big window/frame for your main content that takes up all but one pixel on the screen. At the bottom of the page you will have a 1 pixel-wide (almost invisible) blank space that holds the embedded sound file. Since the midi frame remains stable and only the main content frame changes, the sound file plays across multiple pages. I would not include the sound control panel if I was using this technique.

Leaving room for the control panel can be tricky, as they are different sizes in Explorer and Netscape Navigator. Navigator’s default control panel is 144wx60h. Explorer’s is 200wx60h. The dimensions are in pixels.

A saner solution for your users is to have a link to sound, giving them the option to play it — or not. Just link the file as a regular link:

<A HREF=”soundfile.mid”>play music</A>

I often include a little icon – a speaker, a note, an ear – to indicate that there is a sound file to play.

So where do you get sound files to embed? There are many places on the Internet: get a long list by searching on Google for “free midi” or “free wav.” Or

Midi is your best bet for embedded music. It’s synthesized sound that uses the sound card as part of the encoding, so the files are small. The long midi sequence I used in the sample on the Web site is only about 12KB. Midi files can sound cheesy, so be discriminating. Popular songs will have many midi renditions, so listen to a few and select the best.

Wav files are much, much bigger — perhaps as much as 10MB for the same length clip. They can sound just like they are from the CD, but no one is going to wait for a 10MB file to download just to listen to background music. Wav files are more likely to be used for short sound files, like dialogue from films.

If there are problems, make sure that your server is configured with the correct MIME type. I can’t imagine a public server not configured for Midi or Wav, but you never know.

There are, of course, other kinds of sound files that you can use. On the San Antonio Vocal Arts Ensemble site I used MP3 files. Los Nice Guys use shockwave files for their music and actually embed it using the format I’ve described here. Both of these use exceptionally high quality sound with a small file size.

Another option is RealAudio. This is a streaming media, which means that it trickles across the wires little by little, so the whole sound file doesn’t have to load before it starts playing. There’s a trick to linking to RealAudio files. The actual RealAudio sound file has a link of .ra. The link that shows up on your Web site should be to an .ram file that points to the .ra file. You create the .ram file in notepad; all it needs is the complete URL of the .ra file. Call it something like song1.ram.

If you want a Web site that will make your heart sing, by all means include links to music files but even though you now know how, think twice before you push a sound file onto your unwary users.
 


Copyright© 1996-2010
Alamo PC Organization, Inc.
San Antonio, TX USA