2011-03-29 120 views
2

我想从MPMoviePlayer(例如:http://localhost/api?file_id=2313mk)从URL播放视频(MP4)文件,但无法让它工作,想知道是否有任何解决方案。MPMoviePlayer无法播放没有扩展名的URL的视频流

很少试验如下进行:
1)在计算机的浏览器Play网址:SUCCESS
2)在iPhone上播放URL(4.2+)的浏览器/ MPMoviePlayer:FAILED
3)复制文件和重命名,然后在iPhone浏览器中播放/ MPMoviePlayer从扩展新的URL(如:http://localhost/video.mp4):成功
4)检查头的内容类型(视频/ MP4):EXISTS

为无扩展URL响应头:(例如:HTTP://本地主机/ 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 
+0

它实际上适用于mp3格式,如果服务器的url(例如:http:// localhost/api?file_id = 2313mk)返回mp3 – alvinsj 2011-03-30 04:11:42

回答

0

您的测试结果表明,“视频/ MP4” MIME类型无法识别。与文件扩展名的视频播放,无论内容类型,因为扩展名为“MOV”被称为属于一个电影文件:

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

您可以更改内容类型?

+0

Content-Type实际上似乎是正确的,但是为什么/你有什么建议改变? – alvinsj 2011-04-08 05:16:39

+0

对不起,我只做了“下载和播放”或HTTP实况流。第一个基于文件扩展名工作,第二个在服务器开始发送正确的MIME类型后工作。尚未完成动态下载(但),但是我猜想我会尝试“video/mpeg”或“video/quicktime”。我的意思是在服务器端更改MIME类型。 – JOM 2011-04-08 09:59:49

相关问题