Reputation: 283
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>
)
}
Upvotes: 1
Views: 1159
Reputation: 1064
The issue is related to your video format
Html supports only MP4, WebM, and OGG video formats
either you convert your files to a compatible format using some packages like
PHP-FFMpeg
or using some third party solutions like Qencode
Upvotes: 2