Hello, drakes-ga!
You have a few options to cause a sound to play in a web page- namely,
the EMBED and the BGSOUND tags. Here is the rundown on what these tags
are used for:
EMBED: "embeds" a file of some type in a web page. The browser can
decide how to handle this file, but usually will handle it based on
its type in an external plugin or application. With Netscape/Mozilla,
this is the best way to cause a background WAV file to play.
However, using EMBED requires that the target system (the person
viewing the web page) have some type of application capable of playing
the sound. This is usually not a problem.
BGSOUND: This is an Internet-Explorer specific tag, and is not
recognized by other web browsers. If your web browser is IE, you can
use this with no problem. However, others that view your website that
don't use IE won't hear the sound.
EMBED should work for most configurations, so I would recommend using
it. However, BGSOUND is a good alternative if you only want to target
Internet Explorer, which is the single largest segment of the browser
market at the moment. You may also wish to try both, although this
might produce strange results on some systems- I have not tested this
myself, although some web sites I read did recommend this approach to
cast the widest net possible, so to speak.
Here is how to use EMBED:
<EMBED SRC="your_file.wav" AUTOSTART="true" HIDDEN="true" LOOP="1">
This will cause the file to be played as a background sound, and have
no display element- in other words, it won't appear on the page. If
you remove the HIDDEN attribute and use HEIGHT and WIDTH attributes,
like so:
<EMBED SRC="your_file.wav" AUTOSTART="true" HEIGHT="100" WIDTH="100" LOOP="1">
it will be displayed in the web page as an "embedded" control, and for
sound files, should have controls to start, stop and adjust volume on
it. The actual appearance might be different depending on the
application used to display it- remember that EMBED causes the browser
to display the file using an external plug-in, such as Windows Media
Player or Apple's QuickTime. The actual display is dependent entirely
on the user's browser and installed applications, and is not
guaranteed to work on every target system.
Here's a tip to using the EMBED tag- use the NOEMBED tag to show users
some type of info if their browser does not support EMBED- like so
<EMBED SRC="your_file.wav" AUTOSTART="true" HEIGHT="100" WIDTH="100" LOOP="1">
<noembed>Your web browser doesn't support playing embedded sounds.</noembed>
This is probably something you should only use if you're not using
HIDDEN="true", as it will simply clutter the page if the browser won't
play the sound.
To use BGSOUND and IE:
<BGSOUND SRC="bgsound.wav" LOOP="1">
This will play the file once. Setting LOOP to "-1" will cause the file
to loop forever, but this may be annoying to your users, so I
recommend caution with this. :)
I recommend checking the following web pages for more background
information and some other tips and tricks:
http://www.tips-tricks.com/sound.asp
http://users.chariot.net.au/~kday/htmlsound.html
http://www.eurekais.com/brock/bksnd.htm <-- good tutorial and information.
Please don't hesitate to ask for an answer clarification if you have
any further questions or if there's anything I can do to help you
further.
Thanks for using Google Answers, and I hope my answer has been of use to you.
Regards,
Cyclometh-ga
Search strategy:
play wav file web page |
Request for Answer Clarification by
drakes-ga
on
29 Mar 2004 19:54 PST
I had a couple follow up thoughts.
My wav file is about 1 meg.
Is that to big or it will stream the music so size really doesn't matter?
And will it loop when done.
thanks so much
Andy
By the way great answer!
|
Clarification of Answer by
cyclometh-ga
on
29 Mar 2004 20:03 PST
Hi again, drakes-ga!
I believe that the answer to your question is a qualified "yes",
although many factors are at work- namely, the user's configuration,
network speed, and the plugin used to play the file in the case of
using EMBED. If you use BGSOUND, I'm not certain, although it would be
my educated guess that Internet Explorer would begin to play the file
as it became available, meaning that it would play it as it
downloaded- this is only a guess, however. I would recommend testing
this out.
I would recommend testing this configuration using a few different
systems, or get some friends on different connections and using
different browsers to try it out and tell you what happens. Be sure
the cache is cleared on any system you're testing with to make sure
you're fetching the whole file. This will give you an idea of how well
your sound file is performing.
Given that the size is about 1 megabyte, users on slower connections
will have problems accessing your page, because there's only so much
data you can cram down a modem link in a given period of time. This
may or may not be a source of concern, but if you have the opportunity
or ability to test your site on a dialup link, I would give it a try
and see what happens.
As far as whether it will loop or not, the answer is yes- it will loop
to the number specified in the LOOP attribute, or forever if LOOP is
set to "-1" in the case of the BGSOUND tag. I don't know if setting
LOOP to "-1" in the EMBED tag will cause the sound to loop infinitely;
I was unable to locate any definitive documentation on that. If you
want to be sure the sound plays for a good long time, you could simply
set LOOP to an absurdly high value, like 10000 or something.
If the file is not fully downloaded, it will not loop until the file
is finished being retrieved, but once it is fully available, it will
loop.
And thank you for your kind comment- it's appreciated. :) Once again,
thank you for using Google Answers, and don't hesitate to ask if
there's anything more I can do for you.
Regards,
Cyclometh-ga
|
Request for Answer Clarification by
drakes-ga
on
30 Mar 2004 06:58 PST
What about Macs?
Someone told me at work that the music won't play on a mac.
Is this true.
as
|
Request for Answer Clarification by
drakes-ga
on
30 Mar 2004 11:08 PST
One more thing.
Many of the computers at my place of work are getting an error when my
webpage loads.
"plug in error
the data that the program requested did not download successful"
The music plays fine but this dialog box opens with this error.
Oh...it does play on a Mac
Andy
|
Clarification of Answer by
cyclometh-ga
on
30 Mar 2004 15:19 PST
Hello again, drakes-ga-
Unfortunately, I'm not sure what could be causing that problem, as
it's dependent on the software the user is running to play the WAV
file. It is likely related to either the size of the file or the
plugin being used.
You may want to see how well it works on the latest versions of IE
with QuickTime (http://www.apple.com/quicktime/). I have had very few
problems playing sounds with QuickTime.
One of the biggest problems you will run into is, unlike text, audio
is much more system-dependent. Some systems don't even have audio
capabilities- although that is rare these days.
If you continue to have problems, I would advise searching Google
Groups (http://groups.google.com) to see if others have had similar
issues to yours and what the resolution, if any, is.
Best regards,
Cyclometh-ga
|
Request for Answer Clarification by
drakes-ga
on
31 Mar 2004 06:46 PST
I figured out the problem...thank you.
One more problem.
I wanted to see how the music sounded when I used dial-up service
rather then cable.
I got a bad result...very choppy.
I feel it has something to do with the size of the file...I could be wrong.
Any advice.
Thanks again for all your help!
Andy
|
Clarification of Answer by
cyclometh-ga
on
31 Mar 2004 12:36 PST
Hello drakes-ga!
Yes, you are correct in your assessment about the size of the file
affecting the playback on dialup connections. Unfortunately, this is a
limitation of dialup connections, as they simply can't transmit data
quickly enough to get a continuous playback. You could use some
optimizations, such as reducing the file size or audio quality of the
file- make it mono instead of stereo, reduce it to 8-bit, and so on.
However, the quality of the audio may suffer in this case. You'll have
to find the right balance that suits your site.
Good luck!
Regards,
Cyclometh-ga
|