2
votes

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
2
it actually works for mp3 format, if server url(e.g.:localhost/api?file_id=2313mk) returns a mp3alvinsj

2 Answers

0
votes

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?