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
Ok, not that you have the basics on embedding sounds, let's play with the parameters a little. The tags on this page primarily apply to <embed> tags because most won't work on <bgsound> tags. So far, you've only seen autostarts and hidden files. Time to bring the files out of hiding.


Hidden
So far, you have only had hidden files. You have learned two ways of making embedded sounds hidden. This first is to add the note "hidden=true" into the tag.
<embed src="trumpet.wav" hidden=true></embed>
The other way was to keep it visible, but make it zero pixels by zero pixels. This is also a way to hide it.
<embed src="trumpet.wav" width="0" height="0"></embed>
Tho other option is to make it visible. To make it visible, just make it plain:
<embed src="trumpet.wav"></embed>
Here's what that looks like:
You'll notice that you can control the sound, but it starts on its own and might get a little disruptive. One way to control that is through "autoplay."


Autoplay
The "autoplay" command has two settings; true and false. When it is set to true, it will start the music immediately. If it is set to false, the user must hit the play button. Here is the code and what it looks like:
<embed src="trumpet.wav" autoplay="false"></embed>


That bar is big and cumbersome, but you can make it smaller. That's why you'll next learn width and height commands.


Width and height
This time we'll add width and height commands to the sound. Here ya go:
<embed src="trumpet.wav" autoplay="false" width="144" height="40"></embed>

That's a little awkward, but it can be useful. Another way of controlling the height and width is through "console" features.


Controls
Look at this one:
<embed src="trumpet.wav" autoplay="false" width="144" height="40" controls="smallconsole"></embed>

Sometimes you can change the size of the display using these commands. Some computers read them better than others though, so good luck. Another use for "controls" is choosing which buttons you'd like to display. Here we go with that:
<embed src="trumpet.wav" autoplay="false" width="35" height="23" controls="playbutton"></embed>




Looping
So far, we've only had a sound that loops once, but it's possible to get a sound to loop several times, or even forever. Please don't do this though. It's nastily annoying. I'll show you how to do it, but please promise you won't use it. Please? Do you want to know why?

Embed:
<embed src="trumpet.wav" autoplay="true" hidden="true" loop="true" ></embed>


This one will loop forever. Please, for heaven's sake, don't use it.
<embed src="trumpet.wav" autoplay="true" hidden="true" loop="2" playcount="2" ></embed>


This one will loop twice. Some computers will read the "loop" command and some will read the "playcount" command, so it's best to include both.
Bgsound:
<bgsound src="trumpet.wav" autostart="true" loop="infinite" ></bgsound>


This one will loop forever. Note that it says "autostart" instead of "autoplay".
<bgsound src="trumpet.wav" autostart="true" loop="2" ></bgsound>

Keep in mind that there is no guarantee any of these will work on other people's computers. Use at your own risk.


Volume
One last thing. You can sometimes set the volume of your sound. The default volume is 50%, but you can set it anywhere from zero to 100%. Here we go:
<embed src="trumpet.wav" autoplay="false" volume="10" ></embed>

<embed src="trumpet.wav" autoplay="false" volume="100" ></embed>

Once again, you're at the mercy of the operating system of the user, but it sometimes works. Good luck.

Back Home Forward