如何使用 HTML5 将音频合并到网站中?

发布于 2024-12-03 06:47:02 字数 292 浏览 0 评论 0原文

我被要求为客户制作一个微型网站,他们希望它成为一个包含音频旁白的演示风格网站。

他们要求用 HTML5 来完成,但我还没有用 HTML5 制作任何东西。他们还希望它能够覆盖更广泛的受众,那么 HTML5 是否适用,最低的浏览器要求是什么?

除了 Flash 之外,还有一种方法可以为页面生成配音...也许是 jQuery 或者其他什么?

选项是否是

  • HTML5,浏览器支持有限
  • 基于 Flash 的网站,无法在 iPad/手机上查看 无
  • 旁白!

I have been asked to produce a microsite for a client and they want it to be a presentation style website that will include audio narration.

They asked for it to be done in HTML5, but I haven't produced anything in HTML5 yet. Also they want it to reach a wide audience, so would HTML5 be applicable, what are the minimum browser requirements?

Other than Flash is there a way of producing voiceover for pages... jQuery maybe or anything else?

Would the options be

  • HTML5 with limited browser support
  • Flash based website which can't be viewed on an iPad/Phone
  • No narration!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

杀お生予夺 2024-12-10 06:47:02

每当您使用 HTML5 进行开发时,您都应该考虑提供向后兼容性的方法。

要确定最低浏览器要求,请访问此处:http://en.wikipedia.org/wiki/Comparison_of_layout_engines_ (HTML5)

使用 HTML5 音频:
http://www.w3schools.com/html5/html5_audio.asp

对于 HTML5 音频,您将需要至少两个声音文件副本才能访问每个浏览器:我会说一个是 mp3 格式,另一个是 Ogg Vorbis 格式。

您可以使用简单的浏览器检测 JavaScript 来确定浏览器并相应地提供内容: http://javascript.about .com/library/blbrsdet.htm

一般来说,最佳实践是确定支持,然后按顺序回退:

  1. 如果支持 HTML5,请使用
  2. 如果不支持支持HTML5,测试flash支持。如果可以,则提供 Flash 音频。
  3. 如果两者都没有,则显示一段包含旁白内容的文本。

从本质上讲,始终提供最新、最好的服务,但首先要支持那些帮助您实现这一目标的技术。

Any time you're developing with HTML5, you should consider ways to offer backward compatibility.

To determine minimum browser requirements, please visit here: http://en.wikipedia.org/wiki/Comparison_of_layout_engines_(HTML5)

Using HTML5 Audio:
http://www.w3schools.com/html5/html5_audio.asp

For HTML5 Audio, you will need at least two copies of the sound file to hit every browser: I would say one in mp3 format, the other in Ogg Vorbis.

You can use a simple browser detection javascript to determine browser and serve content accordingly: http://javascript.about.com/library/blbrsdet.htm

Generally, best practice would be to determine support, then fall back in order:

  1. If they support HTML5, use <audio>
  2. If they don't support HTML5, test for flash support. If ok, serve flash audio.
  3. If neither, display a block of text with the content of the narration.

Essentially, always serve the latest and greatest, but support the technologies that got you there in the first place.

客…行舟 2024-12-10 06:47:02

此代码应该高度兼容(IE6+),使用 WAVE:

<![if (!IE)|(gte IE 9)]>
<audio id="speak" src="speak_a.wav" type="audio/wav"></audio>
<a href="#" onclick="document.getElementById('speak').play()">Speak</a>
<![endif]>
<!--[if lt IE 9]>
<bgsound id="speak" name="speak" autostart="false" loop="1">
<a href="#" onclick="document.all['speak'].src='speak_a.wav'">Speak</a>
<![endif]-->

另一种选择,同时使用 mp3/ogg 并且仍然非常兼容:

<![if (!IE)|(gte IE 9)]>
<audio id="speak">
  <source src="speak_a.ogg" type="audio/ogg" />
  <source src="speak_a.mp3" type="audio/mpeg" />
  <a href="speak_a.mp3">Download speak_a.mp3 if you cannot play it</a>
</audio>
<a href="#" onclick="document.getElementById('speak').play()">Speak</a>
<![endif]>
<!--[if lt IE 9]>
<bgsound id="speak" name="speak" autostart="false" loop="1">
<a href="#" onclick="document.all['speak'].src='speak_a.mp3'">Speak</a>
<![endif]-->

如果您不需要支持 IE9 及更早版本,则 标签应该足够了:

<audio id="speak">
  <source src="speak_a.ogg" type="audio/ogg" />
  <source src="speak_a.mp3" type="audio/mpeg" />
</audio>
<a href="#" onclick="document.getElementById('speak').play()">Speak</a>

另一种播放音频的旧方式:

<object data="speak_a.wav" type="audio/wav">
  <embed src="speak_a.wav"></embed>
</object>

您还可以使用第三方库,例如 audio.js

This code should be highly compatible (IE6+), using WAVE:

<![if (!IE)|(gte IE 9)]>
<audio id="speak" src="speak_a.wav" type="audio/wav"></audio>
<a href="#" onclick="document.getElementById('speak').play()">Speak</a>
<![endif]>
<!--[if lt IE 9]>
<bgsound id="speak" name="speak" autostart="false" loop="1">
<a href="#" onclick="document.all['speak'].src='speak_a.wav'">Speak</a>
<![endif]-->

Another option, using both mp3/ogg and still very compatible:

<![if (!IE)|(gte IE 9)]>
<audio id="speak">
  <source src="speak_a.ogg" type="audio/ogg" />
  <source src="speak_a.mp3" type="audio/mpeg" />
  <a href="speak_a.mp3">Download speak_a.mp3 if you cannot play it</a>
</audio>
<a href="#" onclick="document.getElementById('speak').play()">Speak</a>
<![endif]>
<!--[if lt IE 9]>
<bgsound id="speak" name="speak" autostart="false" loop="1">
<a href="#" onclick="document.all['speak'].src='speak_a.mp3'">Speak</a>
<![endif]-->

If you don't need to support IE9 and earlier, the <audio> tag should be enough:

<audio id="speak">
  <source src="speak_a.ogg" type="audio/ogg" />
  <source src="speak_a.mp3" type="audio/mpeg" />
</audio>
<a href="#" onclick="document.getElementById('speak').play()">Speak</a>

Another old way of playing audio:

<object data="speak_a.wav" type="audio/wav">
  <embed src="speak_a.wav"></embed>
</object>

And you could also use third-party libraries such as audio.js

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文