Ejemplo n.º 1
1
     */
    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;
            }
            echo fread($this->stream, $bytesToRead);
            flush();
            $i += $bytesToRead;
        }
    }
    /**
     * Start streaming video content
     */
    public function start($path)
    {
        $this->path = $path;
        $this->open();
        $this->setHeader();
        $this->stream();
        $this->close();
    }
}
$stream = new VideoStream();
if ($stream->checkToken()) {
    $stream->start($_SESSION['_video_path']);
}
Ejemplo n.º 2
0
     * 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();
Ejemplo n.º 3
0
//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()
    {