Mohammed Sabir
Mohammed Sabir

Reputation: 354

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.

Upvotes: 8

Views: 19939

Answers (1)

apokryfos
apokryfos

Reputation: 40673

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

Upvotes: 9

Related Questions