5

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

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

我会倾向于HTML5 audio,但我不确定 IE8 是否会支持它(尽管我想对于 IE8 我可以使用 Conditional Comments?)。

关于最佳方式的任何想法?

PS - 我知道,我知道。

4

1 回答 1

5

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]--> 
于 2011-06-21T13:59:57.407 回答