title: Streaming Video: Failure on (most) browsers
body: <p>I am storing my videos outside of web root, and stream them on request. It works perfectly in firefox and chrome - but fails in IE, safari (mac) and iPad.
  IE Reports <code>Error: Unsupported video type or file path</code></p>
  
  <p>The request is made like so: </p>
  
  <pre><code>&lt;video width="600" height="300"&gt;
  &lt;source src="http://myserver.com/getVideo?key=&lt;somehash&gt;&amp;file=video.mp4 type="video/mp4"&gt;
  &lt;/video&gt;`
  </code></pre>
  
  <p><strong>however</strong> if I call the video directly (without streaming, and the location is in web root), it works in every browser, as expected.
  I believe it has something to do with the way I am streaming. Any ideas?</p>
  
  <pre><code>public function actionGetvideo(){
      $filename = $_GET['file'];
      $filepath = $_GET['path'];
  
      if ($_GET['k'] != $this-&gt;gen_access_key($filename)) {
          throw new CHttpException(403, "unauthorized 1");
          exit('access key fail');
      }
      $filepath = '/home/columbin/' . $filepath . $filename;
      if (!file_exists($filepath)) {
          throw new CHttpException(404, "This video does not exist");
          exit('file does not exist');
      }
  
      $content_type = 'video/mp4';
      $filesize = filesize($filepath);
      $fp = fopen($filepath, 'r');
      if (!$fp) exit('no file');
  
      $content_length = $filesize;
      header('Content-Type: '.$content_type);
      header('Content-length: '.filesize($full_request_path));
  
      ob_clean();
      flush();
      $this-&gt;readfile_chunked($filepath);
  }
  
  protected function readfile_chunked($filename,$retbytes=true) {
      $chunksize = 1*(1024*1024); // how many bytes per chunk
      $buffer = '';
      $cnt =0;
      $handle = fopen($filename, 'rb');
      if ($handle === false) {
          return false;
      }
      while (!feof($handle)) {
          $buffer = fread($handle, $chunksize);
          echo $buffer;
          ob_flush();
          flush();
          if ($retbytes) {
              $cnt += strlen($buffer);
          }
      }
      $status = fclose($handle);
      if ($retbytes &amp;&amp; $status) {
          return $cnt; // return num. bytes delivered like readfile() does.
      }
      return $status;
  
  }
  </code></pre>