Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playing Quicktime video on iPhone using HttpHandler and IIS 5.1

I'm trying to stream QuickTime video to an iPhone from an ASP.NET web application using an HttpHandler. When hosting the web application from IIS 5.1 (Windows XP), the video player opens and then displays the error 'The server is not correctly configured'. However, when using IIS 7.5 (Windows 7), the video plays fine.

The production environment is running IIS 6.0 and has the same problem, where attempting to play videos on the iPhone via Mobile Safari displays the error above.

I've checked the Http Headers and they appear to be practically the same between the two servers (apart from a few, such as the Server header, which will obviously be different), except they appear in different order, though I doubt that this is causing the problem.

According to this thread on Google Groups, adding the 'Accept-Ranges: bytes' header can help, though this made no difference for us. I've also added the ETag header, without any luck.

The code actually responsible for sending the file looks something like this:

Context.Response.Buffer = true;
Context.Response.ContentType = "video/x-m4v";

Context.Response.AppendHeader("Content-Disposition", "filename=\"Video.m4v\"");
Context.Response.AppendHeader("Content-Length", "23456789");

Context.Response.AppendHeader("Accept-Ranges", "bytes");
Context.Response.AppendHeader("ETag", GetETag(path));

Context.Response.TransmitFile(path);

The code above which transmits files appears to be functioning correctly and video files play back correctly in all desktop browsers and when hosting from IIS 7.5 on Windows 7. The problem is only apparent when attempting to play video files on the iPhone using Mobile Safari using the above code with the ASP.NET web application being hosted on IIS 5.1 or IIS 6.0.

Has anyone else experienced anything like this and got any ideas on what I can do to get this working?

like image 285
Mun Avatar asked Oct 28 '09 04:10

Mun


2 Answers

After some searching, I came across the article Range-Specific Requests in ASP.NET which describes the exact problem I was having. Implementing the RangeRequestHandlerBase class from this site (with some minor modifications to fit within our existing project structure) seems to have solved the problem, and video playback now operates correctly from IIS5/6.

@Eric - I've upvoted your answer as your comment was a nudge in the right direction. Simply adding the 'Accept-Ranges' header was not sufficient (despite working in IIS7), and the http handler needed to be modified to handle range requests and ensure that the correct data is being sent.

like image 88
Mun Avatar answered Nov 09 '22 21:11

Mun


Why do you set Response.Buffer to true?

You cannot simply add the "Accept-Ranges" header unless you also ensure that the server supports HTTP Range requests. If the client player demands support for Range requests and the server refuses to handle them, it seems logical that the request would be rejected.

You could try using Fiddler as a reverse-proxy and see if the IPhone makes a Range request. http://www.fiddler2.com/Fiddler/Help/ReverseProxy.asp

like image 2
EricLaw Avatar answered Nov 09 '22 22:11

EricLaw