|Perl Monk, Perl Meditation|
Serving video files in specific byte-rangesby goofball (Acolyte)
|on Aug 26, 2011 at 15:00 UTC||Need Help??|
goofball has asked for the
wisdom of the Perl Monks concerning the following question:
Seeking your help, as the cosmic entity known as Google seems to be keeping secrets from me on this topic.
I have a web site that serves video files, but I can't just leave the videos in an un-protected directory because only logged-in users must be able to access them. So I wrote a script, which includes the below snippets, to authenticate the user and then read the video file from disc and "print" that data line-by-line as output. This works great for most applications, but now that I'm trying to serve files to mobile devices like iPhone, this method no longer works. In my research I've learned this is because the mobile browser/video player asks the server for certain data ranges of the video file via multiple requests. Any modern HTTP server handles this behavior automatically, but when my script fails to serve the video fie in the requested chunks, the mobile device sees the file as broken and will not play it.
Could anyone please advise me on how to re-work this script so that I can serve video files in the requested byte ranges?
Unfortunately, neither of these alternatives is working for mobile clients, although both work fine when the client is a desktop browser.
K.I.S.S. me, I'm stupid!