/** * Constructor */ public function __construct() { if (is_object(self::$instance)) { return self::$instance; } $this->buffer = 102400; $this->start = -1; $this->end = -1; $this->size = 0; @session_start(); self::$instance = $this; }
/** * perform the streaming of calculated range */ private function stream() { $i = $this->start; set_time_limit(0); while (!feof($this->stream) && $i <= $this->end) { $bytesToRead = $this->buffer; if ($i + $bytesToRead > $this->end) { $bytesToRead = $this->end - $i + 1; } $data = fread($this->stream, $bytesToRead); echo $data; flush(); $i += $bytesToRead; } } /** * Start streaming video content */ function start() { $this->open(); $this->setHeader(); $this->stream(); $this->end(); } } $stream = new VideoStream("." . $_GET['file']); $stream->start();
//Imports require_once 'db/db_conn.php'; require_once 'db/SELECT.php'; require_once 'classes/File.php'; if (!isset($_GET['_']) || !is_numeric($_GET['_'])) { http_response_code(404); exit; } $con = connect_db(); $ADK_FILE = new File(); $ADK_FILE->id = intval($_GET['_']); $ADK_FILE->get($con, false, false); $con->close(); if ($ADK_FILE->name != '') { $videoStream = new VideoStream('../uploads/' . $ADK_FILE->savename[0] . '/' . $ADK_FILE->savename[1] . '/' . $ADK_FILE->savename); $videoStream->start(); } class VideoStream { private $path = ''; private $stream = ''; private $buffer = 102400; private $start = -1; private $end = -1; private $size = 0; function __construct($filePath) { $this->path = $filePath; } private function open()