2

I want to add a sound in my page that autoplays but it seems like all ways require some plugin or codex or idk so I'm not quite sure what is the best audio format and way to code it so it works for most users and browsers.

Is there some way to works for most people?

Thanks

lisovaccaro
  • 32,502
  • 98
  • 258
  • 410

1 Answers1

2

you can use BGSOUND tag like this :

<BGSOUND SRC="waitng2.wav" LOOP="2"> 

but only accepts WAV and MID formats.

for MP3 formats you can use EMBED tag but in some browser need plugin to be played.

<embed src="http://www.davesite.com/webstation/html/davesite.mp3" 
   loop="true" autoplay="false" width="145" height="60"></embed>

you can also use compination of these two ways to correct compatablity problem:

<NOEMBED><BGSOUND SRC="waitng2.wav" LOOP="2"></NOEMBED>
<EMBED SRC="waitng2.mp3" HEIGHT="0" WIDTH="0" AUTOSTART="TRUE"></EMBED> 
Farzin Zaker
  • 3,578
  • 3
  • 25
  • 35
  • I couldn't make it work in firefox. I tried the three codes. I can't make anything work in firefox. I'm using Chrome too and it autoplays with no problems – lisovaccaro Apr 25 '11 at 07:27
  • Firefox 4. I'm in Ubuntu, I don't think that has anything to do it but I'll test it later in windows. Thanks – lisovaccaro Apr 25 '11 at 07:54
  • I didn't get around to test it on windows, but everyone says this is the correct approach – lisovaccaro Apr 26 '11 at 04:50