1. Go to this page and download the library: Download micilini/video-stream library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
micilini / video-stream example snippets
ilini\VideoStream\VideoStream;
// Local video
$stream = new VideoStream();
$stream->local('/var/www/videos/movie.mp4')->output();
ilini\VideoStream\VideoStream;
// Remote video
$stream = new VideoStream();
$stream->remote('https://cdn.example.com/video.mp4')->output();
ilini\VideoStream\VideoStream;
// Remote video with cache
$stream = new VideoStream();
$stream->remote('https://cdn.example.com/video.mp4')
->cache(
enabled: true,
ttl: 3600,
fresh: false,
path: '/tmp/video-cache',
maxDisk: 10 * 1024 * 1024 * 1024
)
->output();
use Illuminate\Support\Facades\Route;
use Micilini\VideoStream\Laravel\VideoStreamFacade as VideoStream;
Route::get('/video/{file}', function (string $file) {
$path = storage_path("app/videos/{$file}");
return VideoStream::local($path)->stream();
});
Route::get('/stream', function () {
$url = request('url');
return VideoStream::remote($url)
->cache(enabled: true)
->stream();
});
use Micilini\VideoStream\VideoStream;
use Symfony\Component\HttpFoundation\Response;
class VideoController
{
public function play(): Response
{
$stream = new VideoStream();
return $stream->local('/path/to/video.mp4')->stream();
}
}
use Micilini\VideoStream\VideoStream;
$stream = new VideoStream();
$stream->local('/path/to/video.mp4')->output();