<script>var player = videojs('example_video_1');player.nuevo({ video_id:"v1234", downloadButton:true });</script>
<script>player.on('downloadVideo', function(event,data){video_url = data.source;video_id = data.id;//send file to server-side file with download function });</script>
<script>window.location(download.php?url=video_url);orwindow.location(download.php?video_id=video_id);</script>
<?php$video_url = trim($_GET['url']);
header('Content-Description: File Transfer');header('Content-Type: application/octet-stream');header('Content-Disposition: attachment; filename='.basename($file));header('Content-Transfer-Encoding: chunked');header('Expires: 0');header('Cache-Control: must-revalidate, post-check=0, pre-check=0');header('Pragma: public');$stream = fopen('php://output', 'w');$ch = curl_init($file);curl_setopt($ch, CURLOPT_READFUNCTION, function($ch, $fd, $length) use ($stream) {return fwrite($stream, fread($fd, $length));});?>
<?php$video_url = trim($_GET['url']);$video_id = trim($_GET['id']);
// your code to get relative file path of video, based on video url or based on video_id and information stored in database for example.// the result store in $filepath variable
if (file_exists($filepath) && is_file($filepath) && is_readable($filepath)) {ini_set('memory_limit', '-1');@ob_end_clean();if(ini_get('zlib.output_compression')) {ini_set('zlib.output_compression', 'Off');}header('Content-Type: application/force-download');header('Content-Disposition: attachment; filename="'.basename($file).'"');header('Content-Transfer-Encoding: binary');header('Accept-Ranges: bytes');header('Cache-control: private');header('Pragma: private');header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');header('Content-Length: ' .filesize($file)); readfile($file);exit();}die();?>