MPMoviePlayer 无法播放来自不带扩展名的 url 的视频流
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个: http://www.iphonedevsdk.com/forum/iphone-sdk-development-advanced-discussion/15768-mpmovieplayer-video-via-url-glitch.html
Try this: http://www.iphonedevsdk.com/forum/iphone-sdk-development-advanced-discussion/15768-mpmovieplayer-video-via-url-glitch.html
您的测试结果表明无法识别“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:
Can you change Content-Type?