Html HTML5 视频无法在 Firefox 中播放
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15656465/
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
HTML5 video not playing in Firefox
提问by qwerty
I've converted the file to three different formats: mp4, web, and ogv. According to caniusefirefox supposedly supports both ogg and webm, but nothing is playing.
我已将文件转换为三种不同的格式:mp4、web 和 ogv。根据caniusefirefox 应该同时支持 ogg 和 webm,但没有播放。
I converted the files using Miro Converter, according to other people this should work just fine. I believe Chrome picks up the webm file (if i rightclick -> open in new tab, it shows me the webm file), which is great.
我使用Miro Converter转换了文件,据其他人说这应该可以正常工作。我相信 Chrome 会选择 webm 文件(如果我右键单击 -> 在新选项卡中打开,它会向我显示 webm 文件),这很棒。
URL to the site: http://dev.fristil.se/hbh/
网址:http: //dev.fristil.se/hbh/
I have a static image as a background. The video is suppose to display above it, so if it's not moving you can tell it's not working.
我有一个静态图像作为背景。视频应该显示在它上面,所以如果它没有移动,你可以判断它没有工作。
Any ideas?
有任何想法吗?
回答by freshbm
Your server is not sending the correct mime type for the file.
您的服务器没有为文件发送正确的 MIME 类型。
It send Content-Type: text/plain
它发送 Content-Type: text/plain
The HTML5 video may play in Safari, Chrome and IE 9 but not Firefox or IE 7-8. If you fix the MIME-type issue, it will play in Firefox.
HTML5 视频可以在 Safari、Chrome 和 IE 9 中播放,但不能在 Firefox 或 IE 7-8 中播放。如果您修复 MIME 类型的问题,它将在 Firefox 中播放。
If you're using the Apache web server or some derivative of Apache, you can use an AddType directive in your site-wide httpd.confor in an .htaccessfile in the directory where you store your video files. (If you use some other web server, consult your server's documentation on how to set the Content-Type HTTP header for specific file types.)
如果您使用的是 Apache Web 服务器或 Apache 的某些衍生产品,则可以在站点范围的httpd.conf或存储视频文件的目录中的.htaccess文件中使用 AddType 指令。(如果您使用其他 Web 服务器,请查阅您服务器的文档,了解如何为特定文件类型设置 Content-Type HTTP 标头。)
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm
AddType audio/mpeg .mp3
AddType audio/ogg .ogg
AddType audio/mp4 .m4a
AddType audio/wav /wav
You have same question here: Video file .ogv plays locally in Firefox, but not from serverand more detailed answer: https://stackoverflow.com/a/6145629/1081079
您在这里有同样的问题:视频文件 .ogv 在 Firefox 中本地播放,但不是来自服务器和更详细的答案:https: //stackoverflow.com/a/6145629/1081079
回答by Ale
Your problem is server-side. The server is actually returning text/plain
as MIME type for the videos (at least the .ogg one). You will need to adjust your server's configuration to return the correct MIME type so that Firefox can correctly recognize the file. It is the same issue described here: no video with supported format and MIME type found. What does this mean and how can I change this(you just don't see the message because you don't have the controls
option in your <video>
tag).
你的问题是服务器端的。服务器实际上返回的text/plain
是视频的 MIME 类型(至少是 .ogg 类型)。您需要调整服务器的配置以返回正确的 MIME 类型,以便 Firefox 能够正确识别该文件。这与此处描述的问题相同:未找到支持格式和 MIME 类型的视频。这是什么意思,我该如何更改(您只是看不到该消息,因为您controls
的<video>
标签中没有该选项)。
回答by CBroe
Your server delivers the resource http://dev.fristil.se/hbh/wp-content/themes/skal/images/video/bubblybeer.webmwith the HTTP header Content-Type: text/plain
– and therefore Firefox refuses to treat it as anything else.
您的服务器使用 HTTP 标头提供资源http://dev.fristil.se/hbh/wp-content/themes/skal/images/video/bubblybeer.webmContent-Type: text/plain
– 因此 Firefox 拒绝将其视为其他任何内容。
“Teach” your server to deliver such content as video/webm
.
“教”您的服务器提供诸如video/webm
.
(Same goes for your ogv – your server also says that resource would be text, should be video/ogg
instead.)
(你的 ogv 也是如此——你的服务器还说资源应该是文本,应该是video/ogg
。)
回答by zombiedoctor
I was having the same problem w/ webm using the Flowplayer HTML5 player. Firefox said "HTML5 Video Not Found". At first I thought it was Miro having an encode problem and I tried several different programs, all with the same result. So I narrowed it down to either an improper MIME type on my server, transmitting the webm as text/plain (you can use web inspector to see this) or Firefox just sucking. I had the hosting provider AddType video/webm .webm a while ago, so I can't be positive. What I did was just remove the webm reference directly from my HTML after realizing that I had used Flowplayer in the past and only needing a single mp4 file. Firefox can use mp4. Remove this:
我在使用 Flowplayer HTML5 播放器时遇到了与 webm 相同的问题。Firefox 提示“未找到 HTML5 视频”。起初我以为是 Miro 有编码问题,我尝试了几个不同的程序,结果都一样。所以我把它缩小到我服务器上不正确的 MIME 类型,将 webm 作为文本/纯文本传输(你可以使用 web 检查器来查看)或者 Firefox 只是很糟糕。不久前我有托管服务提供商 AddType video/webm .webm,所以我不能肯定。在意识到我过去使用过 Flowplayer 并且只需要一个 mp4 文件后,我所做的只是直接从我的 HTML 中删除 webm 引用。Firefox 可以使用 mp4。删除这个:
<source type="video/webm" src="URL_to_webm.webm" />
That made it work on everything (IE, Chrome, Firefox, iPad, iPhone). Chrome 29 on Mac uses the mp4.
这使它适用于所有东西(IE、Chrome、Firefox、iPad、iPhone)。Mac 上的 Chrome 29 使用 mp4。
回答by yogihosting
I got the same problem in my windows hosting. To solve this i included the mime setting in web.config inside
我在 Windows 托管中遇到了同样的问题。为了解决这个问题,我在里面的 web.config 中包含了 mime 设置
<staticContent>
<mimeMap fileExtension=".webm" mimeType="video/webm" />
</staticContent>