I have a simple a html5 video tag pointing to a mp4 video through php. My problem is that the video starts playing only after it has been completely loaded by the browser.
How should I output video with php? I have used http ranges headers but nothing.
How should I configure apache so that can start playing the video at once (once it has downloaded only a part) ? is there any module should I enable?
html code:
<video width="640" height="264" preload="none" controls="" class="video-js vjs-default-skin" id="approval-playing-video">
<source type="video/mp4" src="dam/index/get-video-preview?id=186&md5=3386d3701e403c69e1c4323168f6ee74"></source>
</video>
Php (ZF2 framework) server code:
$response = new Stream();
$response->setStream(fopen($file, 'r'));
$response->setStatusCode(200);
$response->setStreamName(basename($file));
$headers = new Headers();
$headers->addHeaders(array(
'Content-Type' => 'video/mp4',
'Accept-Ranges' => 'bytes',
'Content-Length' => filesize($file)
));
return $response->setHeaders($headers)->setContent($file);
System test: Centos, Apache 2, PHP 5.4 Test with Firefox 24
Any suggestion will be really helpfull.