The easiest way to distribute sounds and music on the web is by simply linking to an audio file in any well-known and widely-supported format. It is also possible to embed these files in the page so that they play in the background automatically.
This should be done with great care not to annoy the user. If you are convinced that an endlessly looping song is a good thing for your web page, force yourself to sit there and listen to it loop for a good 20 minutes or so. It is difficult to overestimate how annoying bad background music can be! File Format Choices
For very short sound samples (a few seconds or less), .wav files are appropriate. If your music is already in MIDI format, you can simply link to your .mid file. For music recordings, the .mp3 format is by far the most widely known and your visitors are very likely to have a compatible player.
Linking Directly to Audio Files
You can invite a user to play an audio file with a simple link like this:
<a href="mysong.mp3">Listen to my band's latest release now!</a>
Of course you must actually create mysong.mp3 in the first place, and upload it to your web hosting space, placing it in the same folder with the page. If you have not recorded or edited your sound files yet, we recommend Audacity, an excellent piece of free, open-source software that does a fine job of recording and editing audio files. It is suitable for both simple recordings and elaborate multitrack songs. Embedding Audio Files To Play in the Background
Historically, different web browsers have supported different elements for embedding audio files. Fortunately, you can write your HTML to accommodate both approaches and play on all browsers that are capable of playing background audio:
<EMBED SRC="mymusic.mid" HEIGHT="60" WIDTH="145" AUTOSTART="true"
LOOP="true" HIDDEN="true">
<NOEMBED><BGSOUND SRC="mymusic.mid" LOOP="infinite"></NOEMBED>
</EMBED>
Notice that the LOOP attribute has been set to true, and to infinite for browsers that use the BGSOUND element. Think carefully before you do this. Your visitors may appreciate your music more if you do not force them to listen to it over and over! In this case, the embedded song file is a MIDI file called mymusic.mid; but you can do the same trick with MP3 files.
If the music does not play for you, and your browser is not asking you to download a plugin with which to play it, then your web server might not be aware of the correct mime type for MIDI or MP3 files. Your server administrator can adjust this for you. All recently released web server software ships standard with the correct settings for these files.
If you are the web server administrator, and you are running the Apache server, you can add the following line to your httpd.conf file:
AddType audio/x-mp3 .mp3
You will then need to signal Apache to reload its configuration files and restart.