protonemedia / laravel-ffmpeg

This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files.
https://protone.media/en/blog/how-to-use-ffmpeg-in-your-laravel-projects
MIT License
1.62k stars 193 forks source link

How to try catch exception in case playlist is invalid #518

Open jackbaron opened 7 months ago

jackbaron commented 7 months ago

This is my code.

Route::get('/video/secret/{key}', function ($key) {
    return Storage::disk('secrets')->download($key);
})->name('video.key');

Route::get('/video/{playlist}', function ($playlist) {
    return FFMpeg::dynamicHLSPlaylist()
        ->fromDisk('public')
        ->open($playlist)
        ->setKeyUrlResolver(function ($key) {
            return route('video.key', ['key' => $key]);
        })
        ->setMediaUrlResolver(function ($mediaFilename) {
            return Storage::disk('public')->url($mediaFilename);
        })
        ->setPlaylistUrlResolver(function ($playlistFilename) {
            return route('video.playlist', ['playlist' => $playlistFilename]);
        });
})->name('video.playlist');

It working well but when I change the playlist invalid. I got the error ProtoneMedia\LaravelFFMpeg\Http\DynamicHLSPlaylist::parseLines(): Argument #1 ($lines) must be of type string, null given How to try catch this exception in case user intentionally changed playlist parameter.