Skip to content

Commit

Permalink
Merge pull request #28 from FriendsOfREDAXO/skerbis-patch-4
Browse files Browse the repository at this point in the history
declaration fix for poster
  • Loading branch information
skerbis authored Oct 8, 2024
2 parents ccbdb54 + 46386f6 commit 2a3946f
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/video.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Video
{
private readonly string $source;
private string $title;
private string $poster = [];
private array $poster = [];
private array $attributes = [];
private string $a11yContent = '';
private string $thumbnails = '';
Expand Down Expand Up @@ -169,7 +169,6 @@ public function generateFull(): string
$code .= $this->generateConsentPlaceholder($consentText, $videoInfo['platform'], $videoInfo['id']);
}

// Use generate() to create the core media player markup
$code .= $this->generate();

if (!$isAudio && $this->a11yContent) {
Expand Down Expand Up @@ -200,8 +199,7 @@ public function generate(): string
$code .= " src=\"" . rex_escape($sourceUrl) . "\"";
}

// Poster hinzufügen
if (!$isAudio && isset($this->poster)) {
if (!$isAudio && !empty($this->poster)) {
$code .= "<media-poster src=\"" . rex_escape($this->poster['src']) . "\" alt=\"" . rex_escape($this->poster['alt']) . "\"></media-poster>";
}

Expand Down Expand Up @@ -264,21 +262,18 @@ public static function show_sidebar(\rex_extension_point $ep): ?string
$params = $ep->getParams();
$file = $params['filename'];

// Bestehenden Inhalt der Sidebar holen
$existingContent = $ep->getSubject();

if (self::isMedia($file)) {
$isAudio = self::isAudio($file);
$mediaUrl = rex_url::media($file);

if ($isAudio) {
// Einfacher Audio-Player für den Medienpool
$newContent = "<media-player src=\"" . rex_escape($mediaUrl) . "\">"
. "<media-provider></media-provider>"
. "<media-audio-layout></media-audio-layout>"
. "</media-player>";
} else {
// Bestehende Implementierung für Video-Dateien
$media = new self($file);
$media->setAttributes([
'crossorigin' => '',
Expand All @@ -288,7 +283,6 @@ public static function show_sidebar(\rex_extension_point $ep): ?string
$newContent = $media->generate();
}

// Neuen Inhalt zur Sidebar hinzufügen, ohne bestehenden Inhalt zu überschreiben
return $existingContent . $newContent;
}

Expand Down

0 comments on commit 2a3946f

Please sign in to comment.