I would like to show an mp4 through the video tag and the source URL of the video is a URL to a YII application. I was using Yii:app->request->sendFile before but the video wasn't working on the iPad/iPhone so now I'm trying to send the headers myself using the code below but still not working.
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$file_path = "video.mp4";
$file_mime_type = finfo_file($finfo, $file_path);
$file_size = filesize($file_path);
header("HTTP/1.1 206 Partial Content");
header("Accept-Ranges: bytes");
header("Content-Type: $file_mime_type");
header("Content-Length: $file_size");
header("Content-Range: bytes 0-".($file_size-1)."/$file_size");
readfile($file_path);
exit;
I even tried to implement the rangeDownload function from http://mobiforge.com/developing/story/content-delivery-mobile-devices but the problem is that the $_SERVER['HTTP_RANGE'] is always null
even when the request is coming from an iPhone/iPad.
I also tried this solution here mp4 file through php not playing as html5 video but to no avail again..
The code above works fine for a web browser. Also if I access the .mp4 directly from the iPhone/iPad it works fine too so it is not a problem with the video itself
Any help please?
header('Location: video.mp4');
? – cmorrissey$_SERVER['HTTP_RANGE']
isNULL
, why do you send a partial content response? Also if you send a partial content response, why do you send the whole file? Also you need to provide the response headers you generate not only the code, but the actual response. HTTP is here btw: tools.ietf.org/html/rfc2616 – hakre