Forum Moderators: phranque

Message Too Old, No Replies

Background Music

What's the best way of including a background sound?

         

MatthewHSE

5:51 pm on Oct 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay, I know, so background music isn't the best technique around. I hate background sounds myself and don't use them on my pages.

Now that I've made that clear, I'm currently working on one page where an automatic background sound will be downright desirable to me and to the visitors. I'm going to ask you to trust me on that; I'm fully aware of going against one of the cardinal rules of good web design but I have my reasons and have made my decision accordingly! ;)

So anyway, what is currently regarded as the best method of using a background sound that automatically starts and does not loop when the webpage is loaded? CSS? bgsound attribute? Having never done this before, I'm not exactly sure what the implications of each method may be. Therefore any advice is appreciated.

Unless of course the advice is to not do it at all - I've considered the pros and the cons and my decision is made! ;)

Thanks,

Matthew

vkaryl

6:17 pm on Oct 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, I think you can still tweak the "embed" property to auto start and play only once. But seems that I remember that's only Netscape?

You could autoload a player set to autoplay the music once.... either RealPlayer or another media player - problem with that is that some people wouldn't have the right one, and some folks (like me) disable all the players on their machines....

I think the bgsound element/attribute is deprecated? Not sure about that, haven't done sounds for about 10 years. I absolutely have no clue if there's a CSS way to do this.

Gee, I'm just no help at all. Sorry! Oh, hey - here's a thought: find a site that does this, view source and see HOW they did it....

jezra

8:47 pm on Oct 20, 2004 (gmt 0)

10+ Year Member



How about a small flash file that just plays an audio clip once? no graphics no text, just the audio.

encyclo

12:00 am on Oct 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or try the good old-fashioned way. If I remember correctly (I never do this!):

<embed src="music.mid" width="1" height="1" autostart="true" loop="true">
<noembed><bgsound src="music.mid" autostart="true" loop="infinite"></noembed>

It won't validate in a million years, of course - if that is critical, you should look for a Javascript solution.

You'll need to test this in a few modern browsers, though, to see what happens - I don't know how Mozilla/Firefox handles

bgsound
for example. If
bgsound
is supported there, then you may decide to not bother with the
embed
.

The Contractor

12:37 am on Oct 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



believe you can simply use something like the following placed between the head tags which I tried with an mp3. You shouldn't have a problem as long as it is a registered file type with visitors systems:
<bgsound src="filename.mp3" loop="infinite">

EDITED: nope, that only works in IE ...sorry

Here you go htmlcodetutorial.com/sounds/sounds_famsupp_18.html