Reputation: 2394
I'm trying to provide a mp4 file using a ashx handler and it doesn't work on the Iphone. Works in Safari PC though.
I want this to work(ashx):
<video width="100%" height="auto" controls=""><source type="video/mp4" src="play.ashx"></source></video>
Instead of (mp4):
<video width="100%" height="auto" controls=""><source type="video/mp4" src="play.mp4"></source></video>
Here is my code:
public void ProcessRequest(HttpContext context)
{
context.Response.ClearContent();
context.Response.ClearHeaders();
var length = new System.IO.FileInfo(context.Server.MapPath("~/big_buck_bunny.mp4")).Length;
context.Response.CacheControl = "Public";
context.Response.AddHeader("Content-Length", length.ToString());
context.Response.ContentType = "video/mp4";
context.Response.WriteFile(context.Server.MapPath("~/big_buck_bunny.mp4"));
context.Response.Flush();
context.Response.Close();
}
Here is the file if you want to download: http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4
The reason why I have to do this is because client wants to control the access to videos.
Fiddler info(only the differences):
Request Iphone:
User-Agent: AppleCoreMedia/1.0.0.9A405 (iPhone; U; CPU OS 5_0_1 like Mac OS X; en_us)
Accept: */*
Range: bytes=0-1
Accept-Encoding: identity
Connection: keep-alive
Request Safari Windows
User-Agent: QuickTime/7.7.1 (qtver=7.7.1;os=Windows NT 6.1Service Pack 1)
Pragma: no-cache
The responses are identical
Upvotes: 1
Views: 3577
Reputation: 1485
Goto Settings icon on your phone and from Safari options enable plugins. Also make sure that your video is encoded h264 baseline.
Upvotes: 1
Reputation: 42443
On the Request the iPhone sends a Range header. As I find the Safari browser on the mobile devices from Apple picky your server must respond accordingly.
From the specs (paragraph 14.35.2) and your fiddler output you have to start with sending only the first two bytes and respond with an 206, after that the player will probably come back with GET's that has additional headers set.
I have no iPhone or iPad lying around so I can't verify if this answer holds...
Upvotes: 1