Adding sounds and music to your webpage

by Alan Zisman (c) 2002 - read in Czech (Přečtěte si v češtině) and in Portuguese (obrigado a Artur Weber), in Hindi (thanks to Jordan Mendez), in Romanian thanks to Casinority, and in Estonian thanks to Martin Aus

Netscape Composer (and other simple WYSIWYG webpage editors such as the free Kompozer) don't have an easy way to add sounds or music to your page... if you want, you can make a link on your page to a sound or music file, and it will play when the user clicks on the link. That's easy, but isn't what most people want. To make a music or sound file play automatically, however, you need to edit the HTML code by hand.

This is the yucky stuff that you are trying to avoid by using Composer (et al)... but if you want the music to play automatically, you have to do it.

Here's how (using Windows systems as an example. The process is similar on Macs or Linux or using other webpage editors-- but the details will vary):

  • Open your page in Netscape Composer (etc)
  • Click on Edit/HTML Source
  • If your file has not been saved, you'll be prompted to do so...
  • If this is the first time you're doing this in Composer, you'll be asked to select the program to use. Unless you have a better HTML source editing program, you probably want to use Windows Notepad... so browse to yourC:\Windows folder, and pick Notepad.exe (or just type: C:\Windows\Notepad.exe in the dialogue box)
  • The file will be loaded into Notepad, and will look something like this: 

Notepad for editing source code
  • Scroll down almost to the bottom until you see </body> and press Enter to get a new line right above it. Add the following:

<EMBED SRC="Testsound.wav" width=1 height =1 hidden=true autostart=true loop=false>
(It's OK if it takes more than one line, but don't press Enter to break up the line... this assumes, of course, that you have a sound file "Testsound.wav"
  1. If you want the sound to only play once, then loop=false... if you want it to keep playing as long as the page is being displayed, change it to read loop=true
  2. When you are done, save your changes and exit Notepad... you'll see the following message:

Reload File dialogue

    Say Yes. In Composer, you may notice a small  empty box at the bottom of your page... don't worry-- it won't show up when you view your page in a browser. (That's what the hidden=true part of your typing meant!)

    A link:

    HTML And PHP Scripts - Html Code For Adding Music
    Information About HTML History, PHP History, PHP Programming, PHP Basics, HTML Code

Web Page Creation and Maintenance:
Before you begin- an Introduction 
Using Netscape Composer to create web pages 
Webpage Creation hands-on practice 
Using Netscape Gold to create web pages
Adding sounds and music to your webpages  new!
Using WS_FTP to upload and maintain your web pages
Making web animations with free tools new!
Tricks of the trade: Extend Composer with hand coding new!


Search WWW Search

Alan Zisman is a Vancouver educator, writer, and computer specialist. He can be reached at E-mail Alan