简体   繁体   English

通过Javascript将URL解析为HTML5视频元素时,iOS7未检测到Content-Type

[英]iOS7 does not detect a Content-Type, when parsing a URL into a HTML5 video element via Javascript

I'm having an issue where I have a WebView with a video element on it. 我遇到一个带有视频元素的WebView的问题。 It looks something like this: 看起来像这样:

<video id="player" preload controls>
   <source id="source" src="" type="video/x-m4v"></source>
</video>

when I try to load the video through a javascript file it does not load on iOS device: 当我尝试通过javascript文件加载视频时,无法在iOS设备上加载该视频:

var player = dojo.byId("player");
player.src="http://trololoexample.com/trololoEndpoint?id=23454325&type=823405"
player.load()

also I've tried this: 我也尝试过这个:

var source = dojo.byId("source");
domAttr.set(source, "src", "http://trololoexample.com/trololoEndpoint?id=23454325&type=823405")
player.load()

I get this screen: 我得到这个屏幕:

在此处输入图片说明

But when I test this in a web browser the video loads fine... 但是当我在网络浏览器中对此进行测试时,视频可以很好地加载...

Here are some response headers from chrome, which is expected result (with video loading and playing fine): 以下是chrome的一些响应标头,这是预期的结果(视频加载并正常播放):

在此处输入图片说明

And here is a response header from iPad, which is unexpected: 这是来自iPad的响应头,这是意外的:

在此处输入图片说明

also you can see here that it did not recognise the type and shows it as "Other" instead of m4v: 您还可以在此处看到它无法识别类型,而是将其显示为“其他”而不是m4v:

在此处输入图片说明

Can you please help out? 你能帮忙吗? Thanks! 谢谢!

Update: same thing happens for .mov files, they do not load too on iOS 更新:.mov文件也会发生同样的事情,它们不会在iOS上加载

I'm not sure it will help you, but I know the webserver which serves the video file must allow byte-range requests. 我不确定会不会对您有帮助,但是我知道提供视频文件的网络服务器必须允许字节范围的请求。

If it doesn't then you'll get this "nice" picture. 如果没有,您将得到这张“漂亮”的照片。

You might want to look at Appendix A of this page if you run a php web server. 如果运行php Web服务器,则可能需要查看页面的附录A。

Hope this helps 希望这可以帮助

Renaud 雷诺

Looks like I needed a cert to play media files. 看起来我需要证书才能播放媒体文件。

I found the solution here: https://blog.httpwatch.com/2013/12/12/five-tips-for-using-self-signed-ssl-certificates-with-ios/ 我在这里找到了解决方案: https : //blog.httpwatch.com/2013/12/12/five-tips-for-using-self-signed-ssl-certificates-with-ios/

Tip # 5: Consider Creating Your Own Certificate Authority (CA) 提示5:考虑创建自己的证书颁发机构(CA)

or 要么

Tip #4 – Creating Self-Signed Certificates with OpenSSL is Easy 提示4 –使用OpenSSL创建自签名证书很容易

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

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