imanghafoori1 / laravel-video

A laravel package to stream video content.
MIT License
263 stars 40 forks source link

streamVideoFile does not exists, did you mean Stream? #2

Closed davidbonting closed 4 years ago

davidbonting commented 4 years ago

On a fresh installation of Laravel, your example did not workout for me. I did solve it, by looking at your code and manually doing the same thing in my web.php routes:

            $stream = new Iman\Streamer\VideoStreamer($path);
            return $stream->start();

But this:

return response()->streamVideoFile($path);

Didn't workout. Maybe more people are experience this issue? Or do macro's never work directly from web.php?

But all in all, great package!

imanghafoori1 commented 4 years ago

hmmmmmm, I have to test it out. Honestly since I have too many packages I am not that much accurate these days.

adnanhz commented 4 years ago

I am experiencing the same issue on Laravel 5.7

imanghafoori1 commented 4 years ago

I think the return keyword is forgotten.

Could you please go to the vendor folder and change the source code like this:

    public function register()
    {
        Response::macro('streamVideoFile', function ($filePath) {
            return response()->stream(function () use ($filePath) {
                $stream = new VideoStreamer($filePath);
                return $stream->start();
            });
        });
    }

If it did not work, then test this :

    public function register()
    {
        Response::macro('streamVideoFile', function ($filePath) {
                $stream = new VideoStreamer($filePath);
                return $stream->start();
        });
    }

and report me the result, thanks

imanghafoori1 commented 4 years ago

I highly recommend you to install version 2.x there is an other important fix which causes the video to stream more gradually. there is also a config file for you.

davidbonting commented 4 years ago

Sorry for the late reply, but 2.x indeed works, thanks!

Iman\Streamer\VideoStreamer::streamFile($path);