html5音频mp3在firefox中不起作用 [英] html5 audio mp3 not working in firefox
问题描述
我有这个 jsFiddle ,它在Chrome和Safari中完美运行,但在Firefox中不起作用.示例代码:
I have this jsFiddle which works perfectly in Chrome and Safari but does not work in firefox. Sample code:
<!DOCTYPE html>
<html>
<head>
<title>Simple Media Player</title>
<style>
body, div { margin: 0; }
</style>
</head>
<body>
<audio preload="auto" controls autoplay>
<source src="http://dev-audio-test.s3-website-us-east-1.amazonaws.com/08xCf21_niXjQmGmanVUrR0Tk2h2mKSMw_sxg03CrycaxhNiqhX9_NFYhHBw7eJcp_ru52kdQRW88YigtmTE0w==.mp3" type="audio/mpeg" />
</audio>
</body>
</html>
I have set up a simple example of what is not working here it consists of the simple media player (index.html) and a single mp3 as named in the code sample above.
在firefox中进行测试时,音频控件出现然后消失,并且在开发人员工具控制台中显示以下消息:
The audio controls appear and then disappear when testing in firefox and the following message is displayed in the developer tools console:
13:33:01.217 Media resource http://dev-audio-test.s3-website-us-east-1.amazonaws.com/08xCf21_niXjQmGmanVUrR0Tk2h2mKSMw_sxg03CrycaxhNiqhX9_NFYhHBw7eJcp_ru52kdQRW88YigtmTE0w==.mp3 could not be decoded.1 dev-audio-test.s3-website-us-east-1.amazonaws.com
我已经在OS X 10.11.4(Chrome,Safari,Firefox),Ubuntu 14.04(Chrome,Firefox)和Windows 10(Chrome Firefox)上的firefox中对此进行了测试,在所有其他情况下,Firefox均不会播放音频,而其他浏览器做.
I have tested this in firefox on OS X 10.11.4 (Chrome, Safari, Firefox), Ubuntu 14.04 (Chrome, Firefox) and Windows 10 (Chrome Firefox) in all instances Firefox does not playback the audio whilst the other browsers do.
作为对这些评论的回应,当我单击直接链接到可在Firefox中正常播放的mp3.仅使用html标记会发生此问题.
In response to the comments, when I click a direct link to the mp3 it plays fine in Firefox. The issue occurs only with the html tag.
推荐答案
K3N在他的评论中正确提出了该问题:所讨论的音频文件不是MP3文件,而是WAVE文件容器文件,似乎在嵌入MP3编码数据".
我通过在有关的.mp3上执行avconv -i <filename>
确认了这一点.然后,我使用avconv -i <filename> -ar 11025 <new-filename>
重新编码了文件,并创建了一个新的测试链接
K3N correctly presents the issue in his comment "The audio file in question is not a MP3 file but a WAVE file container file which seem to be embedding MP3 encoded data".
I confirmed this by performing avconv -i <filename>
on the .mp3 in question. I then re-encoded the file using avconv -i <filename> -ar 11025 <new-filename>
and created a new test-link here which correctly plays back the .mp3 file in Firefox.
(上述两个avconv
操作都可以使用ffmpeg
执行.)
(Both of the avconv
operations above can be performed using ffmpeg
as well.)
我已经在OS X 10.11.4,Ubuntu 14.04和Windows 10的firefox中对此进行了测试,在所有情况下Firefox都会回放新的重新打包的文件.
I have tested this in firefox on OS X 10.11.4, Ubuntu 14.04 and Windows 10 in all instances Firefox plays back the new repackaged file.
NB.经过进一步调查后,采样率(11025 Hz)不再存在.我在那里进行的测试掩盖了K3N通过正确重新包装.mp3
NB. After further investigation, the sampling rate (11025 Hz) is a non-issue. My tests there masked the issue which K3N raised by properly repackaging the .mp3
这篇关于html5音频mp3在firefox中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!