Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

declaration fix for poster #28

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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