Embedded Sound

Section 1 - Introduction
Section 2 - Basics
Section 3 - Next Level
      Lists
      Basic Tables
      Advanced Text
      Marquee
      Meta
      Sounds
         Sound files
         Links to files
         Embedded files
         More embedded files
         Should you?
         You Try It!
      Comments
Section 4 - Advanced
Section 5 - Publishing
Section 6 - Extras
Appendices
There is another way to put sound into your documents. That is with an embedded sound file. This file can either begin playing automatically or it can be controlled by the user. You get to specify how it's being used. Before adding sound to all of your documents, I suggest reading the section entitles Should you? that you'll encounter in a couple of lessons.

Anyway, the easiest way to embed a sound into your document is with the following command. We'll use the "trumpet.wav" we heard at the beginning of this lesson.:
<embed src="trumpet.wav" hidden=true autostart=true>
If you have already downloaded "trumpet.wav" into your files, this command is enough to get it to play. It will play once, and there will be no visual control panel available.

Is though be noted that Internet Explorer didn't always read the embed tag. It used to use a tag called "bgsound" instead. To get a sound to play, a programmer used to have to type both commands into the code, making it look more like this:
<NOEMBED><BGSOUND SRC="trumpet.wav"></NOEMBED>

<EMBED SRC="trumpet.wav" HEIGHT="0" WIDTH="0" AUTOSTART="TRUE"></EMBED>
A couple of notes here. Netscape ignores what is inside the <NOEMBED> tags, but IE doesn't. In theory, this should be compatible with both IE and Netscape, but there is evidence that more recent versions of IE can read the embed tag. It's kinda a toss-up, but if you have both of these, you should get sound to play.

Compare the two "embed" tags on this page. You'll notice that the first one has "hidden=true" as part of its name. That will make the sound truly background and out of control of the user. The second isn't "hidden" but it sets height and width at zero. This also makes the file virtually hidden.

You might also note that they both say "autostart." This means that the computer automatically starts the sound once the computer loads it. If you have a hidden sound file and it doesn't have autostart, it will never be heard.

The bgsound file automatically hides and starts the file.
Back Home Forward