<视频>在其他浏览器中播放,但不在Safari中播放 [英] <video> plays in other browsers, but not Safari

查看:192
本文介绍了<视频>在其他浏览器中播放,但不在Safari中播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们网站上有MP4视频;它在Mac上的IE9 +,Firefox,Chrome和Chrome中运行良好。但是,在Safari上,视频根本不播放 - 它会触发停顿事件,然后无法加载。我会发布我们的HTML,但我通过发现即使导航到原始MP4的URL也不会播放Safari来进一步追踪问题。当在本地下载和播放时,视频在Quicktime中运行良好。

We have an MP4 video on our site; it plays fine in IE9+, Firefox, Chrome, and Chrome on mac. However, on Safari, the video doesn't play at all - it does trigger a "stalled" event and then nothing loads. I would post our HTML, but I traced the problem further by finding that Safari wouldn't play it even when navigating to the original MP4's URL. When downloaded and played locally, the video works fine in Quicktime.

这是我们所有开发人员中最奇怪的部分,可以获得当我从开发计算机运行相关服务器时,视频可以在Safari上运行。而且,同一目录中的其他MP4文件也存在类似问题。这对我来说是关键,我一直在寻找视频从服务器传输的方式 - 请求/响应标头,确切的文件大小等等。

The weirdest part of this is that of all our developers, I can get the video to work on Safari when I run the related server from my development computer. What's more, other MP4 files in the same directory have a similar problem. This has been the key to me, and I've been searching for any little difference in the way the videos transfer from the server - request/response headers, exact filesize, etc.

从Chrome复制的标题(仅限Safari,因为很难复制/粘贴)

Headers copied from Chrome (only since Safari is harder to copy/paste from)

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
DNT:1
Host:*************:8443
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36

Response Headers
Accept-Ranges:bytes
Content-Length:44875102
Content-Type:video/mp4;charset=UTF-8
Date:Tue, 30 Dec 2014 21:11:51 GMT
ETag:W/"44875102-1419959755000"
Last-Modified:Tue, 30 Dec 2014 17:15:55 GMT
Server:Apache-Coyote/1.1

(另外,以防这会让你想起旧问题;我知道Windows上的Safari已经死了多年。这个问题发生在OS X上)

(Also, just in case this reminds you of an older issue; I'm aware Safari on Windows has been dead for ages. This issue is occurring on OS X)

编辑:可能有所帮助的新信息。我从我自己的网络服务器上获取了一个个人视频,该视频能够在有问题的Safari浏览器上工作,并将其下载到我们服务器的本地视频目录中。 从那里,它遇到与我们其他视频相同的问题。这告诉我MP4本身可能并不重要 - 这可能是我们的Tomcat 7网络服务器的某种服务器问题。我们确实已经正确注册了内容类型,这至少涵盖了基础知识,但我很好奇是否有其他必要的部分。

New info that might help a bit. I took a personal video from my own webserver, which was able to work from there on the problematic Safari browsers in question, and downloaded it to our server's local video directory. From there, it encounters the same issue as our other videos. This suggests to me that the MP4 itself may not matter - this is probably a server issue of some sort with our Tomcat 7 webserver. We do have the Content-Types registered correctly, which at least covers the basics, but I am curious if there are other necessary parts.

更多信息:我没有我想最初提到这一点,但我们正在通过HTTPS连接加载我们的网页和视频。我们的大多数测试服务器都没有有效的证书,因此我们需要点击标准浏览器警告此服务器可能不是它所说的。我们现在正在研究如何在我们所有的服务器上获得正确的证书。

MORE INFO: I didn't think to mention this initially, but we are loading our webpages and videos over an HTTPS connection. Most of our test servers do not have valid certificates, and so we need to click through the standard browser warning that "This server might not be who it says". We are now looking into what it would take to have correct certificates on all our servers.

推荐答案

Safari要求网络服务器支持< a href =http://tools.ietf.org/html/rfc2616#section-14.35 =noreferrer>范围请求标题以播放您的媒体内容。

Safari requires webserver to support "Range" request header in order to play your media content.

https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/CreatingVideoforSafarioniPhone/CreatingVideoforSafarioniPhone.html#//apple_ref/doc/uid/TP40006514-SW6

对于合法的范围请求响应,您的webserve需要返回状态代码206。

For a legit "Range" request response, your webserve need to return status code "206".

这篇关于&lt;视频&GT;在其他浏览器中播放,但不在Safari中播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆