MPMoviePlayer 无法播放来自不带扩展名的 url 的视频流

发布于 2024-10-26 23:01:14 字数 1239 浏览 1 评论 0原文

我正在尝试使用 MPMoviePlayer 从 url 播放视频(mp4)文件(例如: http://localhost/api? file_id=2313mk)但无法使其工作,不知道是否有任何解决方案。

进行了一些测试,如下所示:
1) 在电脑浏览器中播放网址:SUCCESS
2) 在 iphone(4.2+) 浏览器/ MPMoviePlayer 中播放网址:失败
3) 复制文件并重命名,然后从带有扩展名的新网址在 iphone 浏览器/MPMoviePlayer 中播放(例如: http://localhost/ video.mp4): 成功
4) 检查 Content-Type(video/mp4) 的标头:EXISTS

不带扩展名的 url 的响应标头:(例如:http://localhost/api?file_id=2313mk)

HTTP/1.1 200 Download accepted
Date: Tue, 29 Mar 2011 04:48:03 GMT
Server: Apache
Content-Transfer-Encoding: binary
Content-Length: 24897567
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: video/mp4

带扩展名的 url 的响应标头:(例如:http://localhost/video.mp4)

HTTP/1.1 200 OK
Date: Tue, 29 Mar 2011 04:11:19 GMT
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 PHP/5.3.4
Last-Modified: Fri, 18 Mar 2011 05:38:16 GMT
Etag: "d1b78c-17be81f-49ebb2f458200"
Accept-Ranges: bytes
Content-Length: 24897567
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: video/mp4

I am trying to play a video(mp4) file from a url with MPMoviePlayer (e.g.: http://localhost/api?file_id=2313mk) but unable to get it working, wonder if there is any solution.

Few tests are done as below:
1) Play url in computer browser : SUCCESS
2) Play url in iphone(4.2+) browser/ MPMoviePlayer : FAILED
3) Copy file and rename, then play in iphone browser/MPMoviePlayer from the new url with extension (e.g.: http://localhost/video.mp4): SUCCESS
4) Check header for Content-Type(video/mp4) : EXISTS

Response headers for url without extension: (e.g.:http://localhost/api?file_id=2313mk)

HTTP/1.1 200 Download accepted
Date: Tue, 29 Mar 2011 04:48:03 GMT
Server: Apache
Content-Transfer-Encoding: binary
Content-Length: 24897567
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: video/mp4

Response headers for url with extension: (e.g.:http://localhost/video.mp4)

HTTP/1.1 200 OK
Date: Tue, 29 Mar 2011 04:11:19 GMT
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 PHP/5.3.4
Last-Modified: Fri, 18 Mar 2011 05:38:16 GMT
Etag: "d1b78c-17be81f-49ebb2f458200"
Accept-Ranges: bytes
Content-Length: 24897567
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: video/mp4

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白衬杉格子梦 2024-11-02 23:01:14

您的测试结果表明无法识别“video/mp4”MIME 类型。无论内容类型如何,都会播放带有文件扩展名的视频,因为已知扩展名“mov”属于电影文件:

您可以更改 Content-Type 吗?

Your test results suggest that "video/mp4" MIME type is not recognized. Video with filename extension is played regardless of Content-Type, because extension "mov" is known to belong to a movie file:

http://developer.apple.com/library/ios/#documentation/Miscellaneous/Conceptual/iPhoneOSTechOverview/MediaLayer/MediaLayer.html#//apple_ref/doc/uid/TP40007898-CH9-SW6

Can you change Content-Type?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文