Add YouTube video slide type
CI / Deploy / test (push) Successful in 46s
CI / Deploy / deploy (push) Skipped

Admins paste a YouTube link (watch, youtu.be, shorts, live, embed).
The link is checked via oEmbed on save and with a "check link" button
(not found / not embeddable is rejected, unreachable saves with a
warning). Start time can be entered or is taken from the link's
timecode; autoplay is optional. The presenter embeds the video via
youtube-nocookie.com; participants get the link plus a share button
(Web Share API, falls back to copying).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-07 15:08:12 +01:00
1 parent 93aeae1884
commit 1c509e31c2
14 files changed
+972 -24

No files matched your search

+41 -1
View File
@@ -3,6 +3,7 @@ declare(strict_types=1);
namespace App\Model\Entity;
use App\Service\YouTubeService;
use Cake\I18n\DateTime;
use Cake\ORM\Entity;
@@ -34,6 +35,7 @@ class Slide extends Entity
public const TYPE_SCALE = 'scale';
public const TYPE_CONTENT = 'content';
public const TYPE_QUIZ = 'quiz';
public const TYPE_YOUTUBE = 'youtube';
/**
* Quiz phases, see quizPhase().
@@ -63,6 +65,8 @@ class Slide extends Entity
self::TYPE_CONTENT => [],
// time_limit in seconds, 0 = no limit (presenter ends the quiz)
self::TYPE_QUIZ => ['time_limit' => 30],
// url as entered, video_id parsed from it, start in seconds
self::TYPE_YOUTUBE => ['url' => '', 'video_id' => '', 'start' => 0, 'autoplay' => false],
];
/**
@@ -88,6 +92,7 @@ class Slide extends Entity
self::TYPE_SCALE => __('Skala'),
self::TYPE_QUIZ => __('Quiz'),
self::TYPE_CONTENT => __('Inhaltsfolie'),
self::TYPE_YOUTUBE => __('YouTube-Video'),
];
}
@@ -103,6 +108,7 @@ class Slide extends Entity
self::TYPE_SCALE => __('Bewertung auf einer Skala, z. B. 1 bis 5.'),
self::TYPE_QUIZ => __('Frage mit richtiger Antwort und Zeitlimit, aufgelöst wird erst am Ende.'),
self::TYPE_CONTENT => __('Nur Text anzeigen, ohne Abstimmung.'),
self::TYPE_YOUTUBE => __('Video in der Präsentation abspielen, Teilnehmende bekommen den Link zum Teilen.'),
];
}
@@ -121,7 +127,41 @@ class Slide extends Entity
*/
public function isInteractive(): bool
{
return $this->type !== self::TYPE_CONTENT;
return !in_array($this->type, [self::TYPE_CONTENT, self::TYPE_YOUTUBE], true);
}
/**
* @return bool
*/
public function isYouTube(): bool
{
return $this->type === self::TYPE_YOUTUBE;
}
/**
* Link to the video on YouTube incl. start time, null without valid video.
*
* @return string|null
*/
public function youtubeWatchUrl(): ?string
{
$id = (string)$this->setting('video_id');
return $this->isYouTube() && $id !== '' ? YouTubeService::watchUrl($id, (int)$this->setting('start')) : null;
}
/**
* Player URL for the presenter screen, null without valid video.
*
* @return string|null
*/
public function youtubeEmbedUrl(): ?string
{
$id = (string)$this->setting('video_id');
return $this->isYouTube() && $id !== ''
? YouTubeService::embedUrl($id, (int)$this->setting('start'), (bool)$this->setting('autoplay'))
: null;
}
/**