Html Firefox 不会使用 HTML5 <audio> 标签播放 .WAV 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10404005/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Firefox won't play .WAV files using the HTML5 <audio> tag?
提问by David Byers
I'm building a page that will allow a user to upload an MP3 file. That MP3 file is converted in the back end to a .WAV file using LAME.
我正在构建一个页面,允许用户上传 MP3 文件。该 MP3 文件在后端使用 LAME 转换为 .WAV 文件。
The lame execution script is here:
蹩脚的执行脚本在这里:
LAME --resample 44.1 -decode myDirectoryPath/Master.mp3 myDirectoryPath/Master.wav
However, when I use the HTML5 audio tag to create a player for that audio file in Firefox, it doesn't work.
但是,当我使用 HTML5 音频标签在 Firefox 中为该音频文件创建播放器时,它不起作用。
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Test</title>
</head>
<body>
<audio controls>
<source src="myDirectoryPath/Master.mp3">
<source src="myDirectoryPath/Master.wav">
</audio>
</body>
</html>
Everything I've read says that Firefox supports .wav files... and I can't find a simple .mp3 to .ogg command line tool to use that will convert the master.mp3 to .ogg format. Can someone offer some suggestions on what to try next?
我读过的所有内容都说 Firefox 支持 .wav 文件......而且我找不到一个简单的 .mp3 到 .ogg 命令行工具来使用它可以将 master.mp3 转换为 .ogg 格式。有人可以就下一步尝试提供一些建议吗?
I've posted code that works in Safari and Chrome here: http://www.wgbh.org/byers/Audio/index.html
我在这里发布了适用于 Safari 和 Chrome 的代码:http: //www.wgbh.org/byers/Audio/index.html
For whatever reason, FF doesn't like it.
无论出于何种原因,FF 都不喜欢它。
UPDATE(With accompanying facepalm) The issue lies with my LAME decode. The correct syntax is --decode with two dashes instead of one. The system was actually encoding it from mp3 to mp3, naming it wav and Safari / Chrome on the Mac was assuming the file type.
更新(附带facepalm)问题出在我的LAME 解码上。正确的语法是 --decode 用两个破折号而不是一个破折号。系统实际上是将其从 mp3 编码为 mp3,将其命名为 wav,Mac 上的 Safari / Chrome 假定文件类型。
回答by Boris Zbarsky
What's the bit depth on your WAV files? Firefox supports 8-bit and 16-bit PCM, but not other bit depths (12, 20, 24, 32).
您的 WAV 文件的位深度是多少?Firefox 支持 8 位和 16 位 PCM,但不支持其他位深度(12、20、24、32)。
回答by Brian Hadaway
Firefox expects one of the following codecs to be returned as the MIME type:
Firefox 期望以 MIME 类型返回以下编解码器之一:
- audio/wave (preferred)
- audio/wav
- audio/x-wav
- audio/x-pn-wav
- 音频/波(首选)
- 音频/音频
- 音频/x-wav
- 音频/x-pn-wav
Make sure your server returns one of those MIME types for wav files.
确保您的服务器为 wav 文件返回这些 MIME 类型之一。
回答by sfnd
In addition to the bit depth issue, Firefox HTML5 audio apparently does not play back 6-channel audio, either. For my app, I needed to re-rip to change both bit depth and number of channels (e.g. sox inFile-b 16 -c 2outFileotherParams).
除了位深度问题,Firefox HTML5 音频显然也不能播放 6 声道音频。对于我的应用程序,我需要重新翻录以更改位深度和通道数(例如 sox inFile -b 16 -c 2 outFile otherParams)。
回答by ava
This is bug in Firefox - you need to list the MP3 format source to the end, and it will work.
这是 Firefox 中的错误 - 您需要将 MP3 格式源列出到最后,它会起作用。