HTML 5音频(Firefox)

时间:2012-06-13 23:27:18

标签: html5 audio

我有点像HTML 5新手。我遇到的问题是标签在Firefox中运行。

我使用的代码是:

<audio src="Repipe-WebsiteNevada_06-24-08.ogg" controls autoplay>  
  <span class="style19"><a href="Repipe-WebsiteNevada_06-24-08.mp3">
      A message from Repipe Specialists</a></span>
</audio>  

它在本地工作,但是当我上传并测试它时。音频播放器根本没有出现。

这是页面:

http://www.repipespecialists.com/landing/ctc/repipe_specialists_usa_test.html

有人可以帮忙吗?

3 个答案:

答案 0 :(得分:1)

您需要使用type标签指定您正在使用audio / ogg。像

这样的东西
<audio controls autoplay>
  <source src="file.ogg" type="audio/ogg" />
  <source src="file.mp3" type="audio/mp3" />
</audio>

(注意如何将多个文件列为不同浏览器的后备。)


之后,您仍然需要配置服务器。 This StackOverflow answer他可能会提供帮助。

答案 1 :(得分:0)

我认为这与您的服务器端矿山类型配置以及浏览器如何解释不同内容类型的响应有关。

ogg文件的响应内容类型为text/plain,我猜对于某些浏览器(如Chrome),它能够预测真正的内容类型是ogg,但Firefox无法做到这一点。 因此,Firefox将无法将此文件作为ogg音频加载。

答案 2 :(得分:0)

<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Tryit Editor v1.5</title>
<link rel="stylesheet" type="text/css" href="/tryit.css" />
<script type="text/javascript">
</script>
<style type="text/css">
body
{
color:#000000;
background-color:#ffffff;
margin:4px;
margin-top:0px;
}

</style>
</head>

<body>
<div style="position:relative;width:100%;margin-top:50px;margin-bottom:0px;">
<div style="width:960px;height:94px;position:relative;margin:0px;margin-left:auto;margin-right:auto;margin-top:5px;margin-bottom:5px;padding:0px;overflow:hidden">
<audio controls="controls">
  <source src="song.ogg" type="audio/ogg" />
  <source src="song.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>

</body>
</html>