Question: I'm trying to load video from php, using mediaelement.js , but its not working.. Its showing "Download File"

```
<video src="http://localhost/readmp4.php?id=111" width="640" height="360" id="player2" controls="controls">
<source type="video/mp4" src="http://localhost/readmp4.php?id=111" />
</video>
<script>
$('video').mediaelementplayer({});
</script>

```

Answer: 
I spent 1.5hours to troubleshoot why the mediaelement wasn't playing audio files returned from php.
darleys's suggestion worked but also adding type="audio/mpeg" also made it work.

`<audio src="stream.php?file=<?php echo urlencode($abs_file);?>" type="audio/mpeg" />`
1. Make sure to camouflage a mp4 as a path instead of a php request url
for example `<video src=/junk/junk.mp4> instead of <video src=video.php?name=junk>`
2. do a htaccess route to a php file, when user request a path route that to a php file that is going to read the video file secured in a location.
 for example ...

> 
> RewriteRule ^junk/(.\*) /preview.php?media=$1 [QSA,L]
> 
> 
> 

1. now in php , make sure to cater to safari (ipad/iphone) request too...

```
<?php
class VideoGroup1 {
   public function preview() { 
       $id = substr($_REQUEST['media'],0,strrpos($_REQUEST['media'],"."));
       $thisMedia = Pillar_Manage_Media::fetchMedia($id);
       //echo Foundry_Useful::unsealit($thisMedia['path']).$thisMedia['mediaid'];
       $file = Foundry_Useful::unsealit($thisMedia['path']).$thisMedia['mediaid'].".mp4";
       $filesize = filesize($file);

       $offset = 0;
       $length = $filesize;

       if ( isset($_SERVER['HTTP_RANGE']) ) {

           $partialContent = true;

           preg_match('/bytes=(\d+)-(\d+)?/', $_SERVER['HTTP_RANGE'], $matches);

           $offset = intval($matches[1]);
           $length = intval($matches[2]) - $offset;
       } else {
           $partialContent = false;
       }

       $file = fopen($file, 'r');

       fseek($file, $offset);

       $data = fread($file, $length);

       fclose($file);

       if ( $partialContent ) {

           header('HTTP/1.1 206 Partial Content');

           header('Content-Range: bytes ' . $offset . '-' . ($offset + $length) . '/' . $filesize);
       }

       header('Content-Type: video/mp4');
       header('Content-Length: ' . $filesize);
       header('Content-Disposition: attachment; filename="' . $file . '"');
       header('Accept-Ranges: bytes');

       print($data);

   }//End Function preview

}//END Class VideoGroup1

```