Domain Registration as low as $14.95

McWebber ©1998

McWebber Free HTML Help - Find the help you need to make your web site look great!
BACK TO HOME PAGE
Advanced Tutorials
Frequently Asked Questions
McWebber Favorite Links

Adding sound to your page is very simple. All you have to do is add a couple of lines of HTML code and upload the sound file to your directory. (Remember: filenames are CASE sensitive.) Microsoft Internet Explorer and Netscape Navigator use different codes. So in order for your sound to work with both Netscape and MSIE you have to use two different codes for your sound if you want most people with a sound card to be able to hear it.

Here is a simple JavaScript that will take care of three browsers with no problems. Of course the viewer has to have a JavaScript capable browser to be able to hear your sound. But these days, that's the majority of the browsers:

<script language="JavaScript">
<!-- Begin
var MSIE = navigator.userAgent.indexOf("MSIE");
var NETS = navigator.userAgent.indexOf("Netscape");
var OPER = navigator.userAgent.indexOf("Opera");
if ((MSIE>-1) | (OPER>-1)) {
document.write("<BGSOUND SRC=sound.mid LOOP=INFINITE>");
   }
else {
document.write("<EMBED SRC=sound.mid AUTOSTART=true HIDDEN=true VOLUME=100 LOOP=true>");
}
// End -->
</SCRIPT>
<noscript>
<a href="sound.mid">Click Here for sound.</a>
</noscript>

The NOSCRIPT info is so a link will appear to your sound file in non-JavaScript browsers.

Be sure the entire line for the embed tag is on one line.

Of course you'll have to change the name of the file from sound.mid to the name of your .mid file.  You can also use this for a .wav file. If you don't want your sound to be hidden on the page, and you want your viewers to have the option of stopping the sound.  Use this tag:

<embed src="sound.mid" autostart="true" height="60" width="144" loop="true">

That tag will work in Internet Explorer 3.+ and Netscape 2+.

You can also link to the sound which will bring up the users default sound player or plugin device.  Just make a link as you normally would:
<a href="sound.mid">Click here for sound.</a>

To have a small window open and play a sound, visit my JavaScript page for the code for that.

For more information on Netscape's sound tag, click here.

Real AudioReal Audio

A very popular tool on the Internet for sound is Real Audio.
In order for your viewer to hear a Real Audio file they will need the plugin. If you use a RA file, it's a good idea to provide a link to the Real Audio site so anyone can download the free player.

To use Real Audio in your page, you need the Real Audio Player 3.0 or better and the Real Audio Encoder, and at least a 28.8 connection. You can download both programs from: http://www.real.com/.

After you make your .ra file from your .wav file you upload the file to your directory just like any other file. Since you don't have a Real Audio server, you have to make what's called a "metafile" to refer to your .ra file. This allows users of Real Audio 3.0 or the Real Video Player to hear your .ra file streaming, without having to download it. If you just link to your .ra file, it will download, then play. The "metafile" is simply a text file. If your .ra file is "music.ra" then it has it's own URL. i.e. http://members.aol.com/screenname/music.ra.
To make your "metafile" simply use Notepad or any plain text editor and make a .txt file. The only thing you put in the .txt file is your .ra file URL. No quotes, no HTML. Upload the .txt file to your directory, then rename it to have a .ram extension. If you called it music.txt, you can rename it music.ram. Now you simply make a link to the .ram file, not the .ra file.
<a href="music.ram">Click here for real audio</a>Anyone using Real Audio 3.0 or better will be sent to the .ra file and receive it streaming. If you want to let them download the file, you can make a link to the .ra file and label it for download. This will not work for Real Audio 2.0. If you want to test whether you have Real Audio 3.0, click here. If you get an alert saying "This isn't a valid Real Audio file", click on Help and About in your player to check your version of Real Audio. If you don't have 3.0 or better, use the link above to upgrade.

Please, download the free RealAudio Plug-in! 

Here's the code for the above control:


LINKS

Here's a list of sites with MIDI files available to download:

McWebber Helped Me
Add To Your Page

Real Audio
Free MIDI Files

This is a helpware site.

HOME | ADVANCED| FAQ | LINKS

Copyright 1998 McWebber.Com All Rights Reserved.