HTML5 音频 支持哪些音频格式 [英] HTML5 audio what audio formats are supported

查看:7

问题描述

我希望使用 HTML5 在我的 web 应用程序中播放简短的声音.我以 3 种格式保存它.wav、mp3 和 ogg

I have short sound that I wish to play in my webapp using HTML5. I save it in 3 formats. wav, mp3 and ogg

我创建了 3 个标签来播放不同的格式.

I created 3 tags to play in different formats.

<audio controls autobuffer>
<source src="random_d5c589b1.wav" type="audio/x-wav">
</audio>

<audio controls autobuffer>
<source src="random_d5c589b1.ogg" type="application/ogg">
</audio>

<audio controls autobuffer>
<source src="random_d5c589b1.mp3" type="audio/mpeg">
</audio>

IE9显示它可以播放mp3并且播放

IE9 shows that it can play mp3 and it plays

FF5显示可以播放wav、ogg.我听不见.

FF5 shows that it can play wav, ogg. I do not hear it.

Chrome 12 可以播放所有 3 种格式,但我什么也听不见.

Chrome 12 is able to play all 3 formats but I do not hear anything.

当我使用不同的音频文件时,我可以在 FF 和 Chrome 中听到它们.但我听不到我需要的.

When I use different audio files I can hear them in FF and Chrome. But I can't hear those I need.

这里是示例:- http://kvartira-n.com/test-site/sound2.html

感谢朱哈娜.问题是我只有 2 个声道扬声器,并且在 Windows 中选择了 5+1.我不清楚为什么,但有些音频 2 通道文件是可听到的,而另一些则不是.

Thanks to Juhana. The problem was that I had only 2 channel speakers and 5+1 was selected in Windows. It is not clear to me why but some audio 2 channel files were hearable and other wasn't.

谢谢大家,问题已经解决了.

Thanks everyone problem is resolved now.

推荐答案

它是特定于浏览器的.例如.ogg 文件适用于 chrome 和 firefox,但不适用于 safari.

It's browser-specific. e.g. The .ogg file works in chrome and firefox but doesn't work in safari.

提供备用音频文件是个好主意.这是 MDN 网络文档的示例.

It's a good idea to provide alternate audio files. Here is the example by MDN web docs.

<audio controls>
  <source src="random_d5c589b1.wav" type="audio/x-wav">
  <source src="random_d5c589b1.ogg" type="application/ogg">
  <source src="random_d5c589b1.mp3" type="audio/mpeg">
</audio>
查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆