admin管理员组文章数量:1316664
I know, I know. It sounds horrific, but it's what the client wants, and they're very set on the idea. It's now e to me to figure out the best way make it happen. Flash would be ideal but the client wants to avoid using it.
It's a digital audio file, so I can convert it to any format that might make things easier (e.g. MP3 or OGG) but it needs to support IE 8+, FF 3.5+, Safari and Chrome at the very least. It needs to autoplay, have hidden controls (I know, I know) and hopefully it will loop.
I would lean towards HTML5 audio, but I'm not sure if IE8 will support it (although I suppose for IE8 I could use Conditional Comments?).
Any ideas on the best way?
PS - I know, I know.
I know, I know. It sounds horrific, but it's what the client wants, and they're very set on the idea. It's now e to me to figure out the best way make it happen. Flash would be ideal but the client wants to avoid using it.
It's a digital audio file, so I can convert it to any format that might make things easier (e.g. MP3 or OGG) but it needs to support IE 8+, FF 3.5+, Safari and Chrome at the very least. It needs to autoplay, have hidden controls (I know, I know) and hopefully it will loop.
I would lean towards HTML5 audio, but I'm not sure if IE8 will support it (although I suppose for IE8 I could use Conditional Comments?).
Any ideas on the best way?
PS - I know, I know.
Share Improve this question edited Jul 22, 2012 at 12:18 Chuck Le Butt asked Jun 21, 2011 at 13:49 Chuck Le ButtChuck Le Butt 48.8k62 gold badges209 silver badges297 bronze badges 01 Answer
Reset to default 5Here's the solution I ended up with. It works with IE7, IE8, IE9, FF3.5, FF4, Safari and Chrome.
<audio id="background_audio" autoplay="autoplay">
<source src="static/audio/clip.ogg" type="audio/ogg" />
<source src="static/audio/clip.mp3" type="audio/mpeg" />
</audio>
<!--[if (!IE)|(gte IE 9)]>
<a href="#" onclick="document.getElementById('background_audio').muted = true; return false">mute sound</a>
<![endif]-->
<!--[if lt IE 9]>
<bgsound id="background_snd" src="static/audio/clip.mp3" autostart="true" loop="1">
<a href="#" onclick="document.all['background_snd'].src=''; return false">mute sound</a>
<![endif]-->
本文标签: javascriptBest way to embed audio in a webpageStack Overflow
版权声明:本文标题:javascript - Best way to embed audio in a webpage? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742007133a2412185.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论