Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stream video in Laravel

I am trying to stream the video in the blade file. Normally video is loading but I am not able to go to and fro.

Here is the link which I followed: https://codesamplez.com/programming/php-html5-video-streaming-tutorial

I have added the class things in my App/VideoStream.php class and in the blade

<?php
$video_path = 'my_video_ath';

$tmp = new \App\VideoStream($video_path);
$tmp->start();

?>


<video controls preload="auto" src="{{ $tmp }}" width="100%"></video>'

Whats issue in this, please help me out.

like image 761
Mohammed Sabir Avatar asked Nov 05 '19 10:11

Mohammed Sabir


1 Answers

The class you're using is to handle the actual range requests. you need to provide a route that uses that as well:

Route::get('stream', function () {
   $video_path = 'my_video_path';

   $tmp = new \App\VideoStream($video_path);
   $tmp->start();
})->name('stream');

Then the HTML will be:

<video controls preload="auto" src="{{ route('stream') }}" width="100%"></video>'

The class in question can be found in Github

like image 135
apokryfos Avatar answered Nov 15 '22 20:11

apokryfos