solve issue in laravel with react

Job ID: 35201265

Budget: $80 – $240 HKD

1

I'm making a video learning platform like udemy using laravel, but i ran into some problems. I am using the https://github.com/rajurayhan/larastreamer larastreamer package and I created a controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Raju\Streamer\Helpers\VideoStream;

class StreamController extends Controller
{
public function stream($filename)
{
$videosDir = config('larastreamer.basepath');
if (file_exists($filePath = $videosDir."/".$filename)) {
$stream = new VideoStream($filePath);
return response()->stream(function() use ($stream) {
$stream->start();
});
}
return response("File doesn't exists", 404);
}
}

The response is status code 206 (partial data) so it should be fine. But my video player is not playing the video. Im using react for frontend and my page looks like this:

import React from 'react';
export default function () {
return (
<section className='pa-1'>
<h1 className="page__title">Stream</h1>

<video src='/api/stream/elr.avi' controls/>
</section>
)
}
Related categories: PHP JavaScript MySQL HTML5 Laravel