HTML Music Tutorial
HTML is easy to write for Web designers who have taken the one-day class. Adding music to a website is just as easy. There are many things you can do with music on a website, and the code involved is pretty straight forward, regardless of the type of musical player. Extensions for audio files include .mp3, .wav, .aiff, .aac and several for Flash including .swf. The code for audio is the same for video and is simply a matter of file name and file path.
-
Song links
-
The easiest way to link to a song download is using the <a href="?"> tags and replacing the question mark with the file path to the song. An example would be <a href="songs/thetwist.mp3">The Twist</a>. This code says that the song "The Twist" is an mp3 file located in a folder called "songs." Everything within the <a href="?"> and </a> tags is the text that appears as a link. When you click the link, "The Twist" the song will download to your hard drive, and your computer's default player (WinAmp, Windows Media Player, Quicktime, etc.) will then play the song. Sometimes it can take a few minutes for the song to download depending on file size. Flash files can be quick and are popular. You simply create the music file using Flash software, upload it and then reference that file in the HTML.
Text Files
-
You can save a list in a text file with the .m3u extension and then reference it in the HTML. All you need to do is create a text file, then make a list of music files, then save. On the HTML within the <embed> tags replace the "?" with the name of the playlist in the code: <embed name="?" src="playlist.m3u">. Replace "playlist.m3u" with whatever you want to call your playlist. You can make a song play when someone arrives at your website, provided the user has an up-to-date browser. Within the embed tags include "autostart=true" for automatic playback or "autostart=false" for no play. Within the embed tags also must be the attribute "hidden" followed by = "true" or "false."
So the HTML might read: <embed src="playlist.m3u hidden="false" autostart="false">.
Playlists
-
There are several ways to create online playlists. You can also stream audio from iTunes or a DJ playlist program such as MegaSeg for Mac or PCDJ for PC and then in the HTML reference the file path of the stream. You can have a list play once or have it repeat indefinitely. To play once, use this code: <BGSOUND SRC=song1.mp3 LOOP=1>. Of course, you would replace "song1" with whatever song you want. Keep in mind the file can exist on any website as long as you use the correct path. If you want the list to play indefinitely, replace "LOOP=1" with "LOOP=INFINITE." The type of player used can be listed within the <embed> or <object> tags. A playlist can also be created using JavaScript, for which you can find a tutorial at <a href="http://javascript.internet.com/miscellaneous/mp3-playlist.html">The JavaScript Source</a>.
-