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