<?php /*$file = "d.mp4"; $file_size = filesize($file); $fp = fopen($file, "rb"); $data = fread ($fp, $file_size); fclose($fp); header ("Content-type: video/mp4"); echo $data; */ $path = 'f.mp4'; if (file_exists($path)) { $size=filesize($path); $fm=@fopen($path,'rb'); $begin=0; $end=$size; if(isset($_SERVER['HTTP_RANGE'])) { if(preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'],$matches)){ $begin=intval($matches[0]); if(!empty($matches[1])) { $end=intval($matches[1]); } } } if($begin>0||$end<$size) header('HTTP/1.0 206 Partial Content'); else header('HTTP/1.0 200 OK'); header("Content-Type: video/mp4"); header('Accept-Ranges: bytes'); header('Content-Length:'.($end-$begin)); header("Content-Disposition: inline;"); header("Content-Range: bytes $begin-$end/$size"); header("Content-Transfer-Encoding: binary\n"); header('Connection: close'); $cur=$begin; fseek($fm,$begin,0); while(!feof($fm)&&$cur<$end&&(connection_status()==0)) { print fread($fm,min(1024*16,$end-$cur)); $cur+=1024*16; usleep(1000); } die(); } ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)