0

I have been struggling over playing an audio file in mozilla firefox browser over the past few days. I wrote a simple code in html

<audio controls="controls" autoplay="true">  
     <source src= "song.mp3" type="audio/mpeg" > </source>
 </audio>

The audio works with chrome but somehow it doesn't with mozilla firefox (even with latest version 22). I even tried with a script as had been hinted in other forums

    <script src="/audiojs/audio.min.js"></script>
    <script>
           audiojs.events.ready(function () {
           var as = audiojs.createAll();
           });
    </script>

But even this works in chrome but not in firefox. Can anyone explain the reason and also give the html code that can play an audio in firefox browser specifically.

4

5 回答 5

1

我不认为 Firefox 支持 MP3 因为许可。

于 2013-06-28T00:22:33.730 回答
0

据我所知,Firefox 不支持 MP3(解释)。但是你可以使用 Flash 来运行 mp3...

于 2013-06-28T00:26:12.577 回答
0

正如这里的许多其他人所说,Firefox 不支持播放 MP3 文件。您最好的选择是将其编码为 Firefox 可以播放的 OGG 格式:

<audio controls>  
   <source src="song.mp3" type="audio/mp3">
   <source src="song.ogg" type="audio/ogg">
</audio>

如果您绝对坚持只想提供 MP3 文件,那么您需要使用 Flash 播放器在 Firefox 中播放 MP3 文件,尽管我不建议这样做。

于 2013-06-28T07:36:27.550 回答
0

这个示例代码可以帮助你。

<!DOCTYPE html>
<html>
<body>
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
 Your browser does not support the audio element.
</audio>
</body>
</html>

请参阅将与 Mozilla 一起使用。

于 2013-06-28T07:01:45.550 回答
0

如果您想播放 Мozilla 的 MP3,您必须使用 javascript api 示例代码:

    <!DOCTYPE html>
<html>
  <head>
    <script src="audio.min.js"></script>
    <script>
      audiojs.events.ready(function() {
        var as = audiojs.createAll();});
    </script>
  </head>

 <body>
    <audio preload="auto">
      <source src="http://cdn02.cdn.gorillavsbear.net/wp-content/uploads/2010/11/gorilla-vs.-bear-november-2010.mp3">
    </audio>


</body>
</html>

您可以在此 URL 中找到所有示例和下载 API:http: //kolber.github.io/audiojs/

于 2015-05-13T09:29:04.507 回答