繁体   English   中英

无法在Firefox中播放Mp3文件

[英]Cant play an Mp3 file in firefox

我刚刚创建了html程序,使用javascript播放Mp3文件。 如果程序从谷歌浏览器运行,它的工作正常,但它不适用于Firefox(版本24,操作系统:ubuntu)。 并且它在控制台中输出一些错误,如"HTTP "Content-Type" of "audio/mpeg" is not supported. Load of media resource http://localhost/phpsound/sound_file.mp3 failed" 我是否需要为firefox安装任何插件才能解决此问题。 请帮我解决这个问题。

Html代码:

<html>
<head>
<title></title>
<meta http-equiv="content-type" content="audio/mpeg">
<script language="JavaScript" type="text/javascript">
function play_sound()
{
 var audioElement = document.createElement('audio');
        audioElement.setAttribute('src', 'sound_file.mp3');
        audioElement.setAttribute('autoplay', 'autoplay');
        audioElement.load();
        audioElement.play();
}
</script>

<body>
<input  type="button"  name="btnOk" id="btnOk" value=" OK " onClick="play_sound();"/>   
</body>
</html>

Firefox无法播放mp3 ,但可以播放ogg格式的文件。

所以你只需要提供一个额外的ogg文件,它应该工作。


如果您想知道原因,请看这个问题: 为什么Firefox不支持<audio>中的MP3文件格式

Audio element()在Firefox中不支持.mp3文件格式,它只支持.WAV和.ogg文件格式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM