laravel-ffmpeg icon indicating copy to clipboard operation
laravel-ffmpeg copied to clipboard

How to try catch exception in case playlist is invalid

Open jackbaron opened this issue 1 year ago • 0 comments

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.

jackbaron avatar Jan 26 '24 04:01 jackbaron