在网页中嵌入音频的最佳方式? [英] Best way to embed audio in a webpage?

查看:69
本文介绍了在网页中嵌入音频的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,我知道。这听起来很可怕,但这是客户想要的,他们非常关注这个想法。我现在想找出实现它的最佳方法。 Flash是理想的,但客户希望避免使用它。

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 come to me to figure out the best way make it happen. Flash would be ideal but the client wants to avoid using it.

这是一个数字音频文件,因此我可以将其转换为任何可能使事情变得更容易的格式(例如MP3)或者OGG)但它至少需要支持IE 8 +,FF 3.5 +,Safari和Chrome。它需要自动播放,有隐藏的控件(我知道,我知道),希望它会循环。

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.

我会倾向于 HTML5音频,但我不确定IE8是否会支持它(虽然我想IE8我可以使用条件注释?)。

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 - 我知道,我知道。

PS - I know, I know.

推荐答案

这是我最终解决的问题。它适用于IE7,IE8,IE9,FF3.5,FF4,Safari和Chrome。

Here'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]--> 

这篇关于在网页中嵌入音频的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆