What is the most “compatible” way of autoplaying s

2020-04-17 04:24发布

问题:

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

回答1:

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>