Spiele Filme in allen Playern über die gespeicherte Qualitätsleiter.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8e77defaca
commit
1fb48783bf
14 files changed
+202
-18
No files matched your search
@@ -4,7 +4,11 @@
|
||||
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Domain\Media\FilmPlayback;
|
||||
use App\Domain\Media\HlsPlaylist;
|
||||
use App\Domain\Media\MediaRendition;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
@@ -39,6 +43,55 @@ public function fileUrl(ContentElementVersion $version): ?string
|
||||
return $this->storedPath($version) === null ? null : route('content.file', $version);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{mode: string, url: string}|null
|
||||
*/
|
||||
public function playback(ContentElementVersion $version): ?array
|
||||
{
|
||||
$version->loadMissing('element');
|
||||
|
||||
if ($version->element?->output_class !== 'film') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$mode = app(FilmPlayback::class)->mode($version->id);
|
||||
$master = MediaRendition::masterPath($version->id);
|
||||
|
||||
if ($mode === 'hls' && is_string($master)) {
|
||||
return [
|
||||
'mode' => 'hls',
|
||||
'url' => route('content.rendition', ['version' => $version, 'datei' => $master]),
|
||||
];
|
||||
}
|
||||
|
||||
$file = $this->fileUrl($version);
|
||||
|
||||
return $file === null ? null : ['mode' => 'file', 'url' => $file];
|
||||
}
|
||||
|
||||
public function rendition(ContentElementVersion $version, string $datei): Response|StreamedResponse
|
||||
{
|
||||
$this->authorizeStaff();
|
||||
abort_unless($this->renditionBelongsTo($version->id, $datei), 404);
|
||||
$disk = Storage::disk('media_derived');
|
||||
abort_unless($disk->exists($datei), 404);
|
||||
|
||||
if (str_ends_with($datei, '.m3u8')) {
|
||||
$body = app(HlsPlaylist::class)->rewrite(
|
||||
$disk->get($datei),
|
||||
$datei,
|
||||
fn (string $target): string => route('content.rendition', ['version' => $version, 'datei' => $target]),
|
||||
);
|
||||
|
||||
return response($body, 200, [
|
||||
'Content-Type' => 'application/vnd.apple.mpegurl',
|
||||
'Cache-Control' => 'private, no-store',
|
||||
]);
|
||||
}
|
||||
|
||||
return $disk->response($datei, basename($datei), ['Content-Disposition' => 'inline']);
|
||||
}
|
||||
|
||||
public function isPending(ContentElementVersion $version): bool
|
||||
{
|
||||
if ($this->storedPath($version) !== null) {
|
||||
@@ -62,6 +115,13 @@ private function storedPath(ContentElementVersion $version): ?string
|
||||
return Storage::disk('media_derived')->exists($file) ? $file : null;
|
||||
}
|
||||
|
||||
private function renditionBelongsTo(int $versionId, string $path): bool
|
||||
{
|
||||
$prefix = 'ableitungen/'.$versionId;
|
||||
|
||||
return ($path === $prefix || str_starts_with($path, $prefix.'/')) && ! str_contains($path, '..');
|
||||
}
|
||||
|
||||
private function authorizeStaff(): void
|
||||
{
|
||||
$user = auth('staff')->user();
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Domain\Media\DeliveryLog;
|
||||
use App\Domain\Media\FilmPlayback;
|
||||
use App\Domain\Media\HlsPlaylist;
|
||||
use App\Domain\Media\MediaRendition;
|
||||
use App\Http\Controllers\Controller;
|
||||
@@ -146,7 +147,7 @@ public function show(Request $request, LicenseArticle $article): View
|
||||
? (int) $metadata['decision_seconds']
|
||||
: null,
|
||||
'playable' => $decision->allowed && is_string($file) && $file !== '' && ($class === 'film' || $class === 'audio'),
|
||||
'playback' => MediaRendition::masterPath($version->id) !== null ? 'hls' : 'file',
|
||||
'playback' => app(FilmPlayback::class)->mode($version->id),
|
||||
'pillars' => $version->element->pillars->pluck('name')->all(),
|
||||
'url' => $decision->allowed
|
||||
? SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
use App\Domain\Entitlement\DecideAccess;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Domain\Media\MediaRendition;
|
||||
use App\Domain\Media\FilmPlayback;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Models\User;
|
||||
@@ -138,7 +138,7 @@ private function present(User $user, StructureNode $node): array
|
||||
if ($node->contentElementVersionId !== null) {
|
||||
$view = $this->open($user, $node->contentElementVersionId, $this->viewAction($node->outputClass));
|
||||
$download = $this->open($user, $node->contentElementVersionId, 'laden');
|
||||
$playback = MediaRendition::masterPath($node->contentElementVersionId) !== null ? 'hls' : 'file';
|
||||
$playback = app(FilmPlayback::class)->mode($node->contentElementVersionId);
|
||||
if ($view !== null && $node->contentElementId !== null) {
|
||||
$path = ContentElement::query()->whereKey($node->contentElementId)->value('thumbnail_path');
|
||||
$poster = ThumbnailRef::url('member.thumbnail', 'element', $node->contentElementId, $path);
|
||||
|
||||
Reference in new issue
Block a user