Here is my PHP code:
Code: Select all
$url = 'http://page.com/file.flv';
$length = get_headers($url);
preg_match('!\d+!', $length[8], $matches);
$file_size = $matches[0];
$info = pathinfo($url);
$ext = $info['extension'];
$mime_type = generateUpToDateMimeArray($ext);
if ( !$mime_type )
{
die('error');
}
header("Pragma: public");
header("Expires: -1");
header("Cache-Control: public, must-revalidate, post-check=0, pre-check=0");
header ("Content-Disposition: attachment; filename=file.".$ext);
header('Content-Type: '.$mime_type);
if(isset($_SERVER['HTTP_RANGE']))
{
list($size_unit, $range_orig) = explode('=', $_SERVER['HTTP_RANGE'], 2);
if ($size_unit == 'bytes')
{
list($range, $extra_ranges) = explode(',', $range_orig, 2);
}
else
{
$range = '';
header('HTTP/1.1 416 Requested Range Not Satisfiable');
exit;
}
}
else
{
$range = '';
}
list($seek_start, $seek_end) = explode('-', $range, 2);
$seek_end = (empty($seek_end)) ? ($file_size - 1) : min(abs(intval($seek_end)),($file_size - 1));
$seek_start = (empty($seek_start) || $seek_end < abs(intval($seek_start))) ? 0 : max(abs(intval($seek_start)),0);
if ($seek_start > 0 || $seek_end < ($file_size - 1))
{
header('HTTP/1.1 206 Partial Content');
header('Content-Range: bytes '.$seek_start.'-'.$seek_end.'/'.$file_size);
header('Content-Length: '.($seek_end - $seek_start + 1));
}
else
{
header("Content-Length: $file_size");
}
header('Accept-Ranges: bytes');
$fd = fopen($url, "r");
fseek($fd, $seek_start);
while(!feof($fd))
{
echo fread($fd, 4096);
ob_flush();
if (connection_status()!=0)
{
@fclose($fd);
exit;
}
}
@fclose($fd);
exit;Code: Select all
<video id="video1" class="video-js vjs-default-skin" poster="http://video-js.zencoder.com/oceans-clip.png" width="640" height="480"
data-setup='{"loadingSpinner": false, "controls" : true, "autoplay" : false, "preload" : "auto"}'>
<source src="http://mypage.pl/videos/video.php" type="video/x-flv">
</video>Thank for your help.