What is the most “compatible” way of autoplaying sound?

三世轮回 提交于 2019-12-20 03:26:08

问题


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> 


来源:https://stackoverflow.com/questions/5775832/what-is-the-most-compatible-way-of-autoplaying-sound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!