I am trying to output an mp4 video file through PHP. When it is used through a flash player (eg. flowplayer) it is working great. But when I'm trying to use it as a source on an html5 video tag or to call directly the php file, it doesn't work.
The code I use is the following:
$filesize = filesize($file);
header("Content-Type: video/mp4");
if ( empty($_SERVER['HTTP_RANGE']) )
{
header("Content-Length: $filesize");
readfile($file);
}
else //violes rfc2616, which requires ignoring the header if it's invalid
{
rangeDownload($file);
}
and rangeDownload
function is from http://mobiforge.com/developing/story/content-delivery-mobile-devices Appendix A.
Even when I use a Content-Range
header (Content-Range:bytes 0-31596111/31596112
), it stucks on downloading 30.13 MB of the video.
max_execution_time
longer than the video? Did you probe for other header differences (Firebug) between static and readfiled file? – Towers