diff --git a/components/ILIAS/UI/src/Implementation/Component/Player/Renderer.php b/components/ILIAS/UI/src/Implementation/Component/Player/Renderer.php index f0c2d790527d..9489d4788a3e 100755 --- a/components/ILIAS/UI/src/Implementation/Component/Player/Renderer.php +++ b/components/ILIAS/UI/src/Implementation/Component/Player/Renderer.php @@ -1,7 +1,5 @@ getTemplate("tpl.audio.html", true, true); - $component = $component->withAdditionalOnLoadCode(function ($id) { - return "$('#$id').mediaelementplayer({stretching: 'responsive'});"; - }); $id = $this->bindJavaScript($component); if ($component->getTranscription() != "") { @@ -75,11 +72,60 @@ public function renderVideo( Component\Component $component, RendererInterface $default_renderer ): string { + if ($this->isVimeo($component)) { + return $this->renderVimeo( + $component, + $default_renderer + ); + } elseif ($this->isYoutube($component)) { + return $this->renderYoutube( + $component, + $default_renderer + ); + } + return $this->renderNative( + $component, + $default_renderer + ); + } + + public function renderVimeo( + Component\Component $component, + RendererInterface $default_renderer + ): string { + + $tpl = $this->getTemplate("tpl.video_vimeo.html", true, true); + + $id = $this->bindJavaScript($component); + + $tpl->setVariable("ID", $id); + $tpl->setVariable("SOURCE", $component->getSource()); + + return $tpl->get(); + } + + public function renderYoutube( + Component\Component $component, + RendererInterface $default_renderer + ): string { + + $tpl = $this->getTemplate("tpl.video_youtube.html", true, true); + + $id = $this->bindJavaScript($component); + + $tpl->setVariable("ID", $id); + $tpl->setVariable("SOURCE", $component->getSource()); + + return $tpl->get(); + } + + public function renderNative( + Component\Component $component, + RendererInterface $default_renderer + ): string { + $tpl = $this->getTemplate("tpl.video.html", true, true); - $component = $component->withAdditionalOnLoadCode(function ($id) { - return "$('#$id').mediaelementplayer();"; - }); $id = $this->bindJavaScript($component); foreach ($component->getSubtitleFiles() as $lang_key => $file) { @@ -101,11 +147,21 @@ public function renderVideo( return $tpl->get(); } - public function registerResources(\ILIAS\UI\Implementation\Render\ResourceRegistry $registry): void - { - parent::registerResources($registry); - $registry->register('./assets/js/mediaelement-and-player.min.js'); - $registry->register('./assets/css/mediaelementplayer.min.css'); - $registry->register('./assets/js/vimeo.min.js'); + protected function isVimeo( + Component\Component $component + ): bool { + if (is_int(strpos($component->getSource(), 'vimeo.com'))) { + return true; + } + return false; + } + + protected function isYoutube( + Component\Component $component + ): bool { + if (is_int(strpos($component->getSource(), 'youtube.com'))) { + return true; + } + return false; } } diff --git a/components/ILIAS/UI/src/examples/Player/Video/video_vimeo.php b/components/ILIAS/UI/src/examples/Player/Video/video_vimeo.php index b2e0133f1677..a0dfbda5509c 100755 --- a/components/ILIAS/UI/src/examples/Player/Video/video_vimeo.php +++ b/components/ILIAS/UI/src/examples/Player/Video/video_vimeo.php @@ -27,7 +27,7 @@ function video_vimeo(): string $renderer = $DIC->ui()->renderer(); $f = $DIC->ui()->factory(); - $video = $f->player()->video("https://vimeo.com/669475821?controls=0"); + $video = $f->player()->video("https://player.vimeo.com/video/669475821"); return $renderer->render($video); } diff --git a/components/ILIAS/UI/src/examples/Player/Video/video_youtube.php b/components/ILIAS/UI/src/examples/Player/Video/video_youtube.php index 78fa66d34419..4a7bbe356d1d 100755 --- a/components/ILIAS/UI/src/examples/Player/Video/video_youtube.php +++ b/components/ILIAS/UI/src/examples/Player/Video/video_youtube.php @@ -28,7 +28,7 @@ function video_youtube(): string $renderer = $DIC->ui()->renderer(); $f = $DIC->ui()->factory(); - $video = $f->player()->video("https://www.youtube.com/watch?v=YSN2osYbshQ"); + $video = $f->player()->video("https://www.youtube.com/embed/YSN2osYbshQ"); return $renderer->render($video); } diff --git a/components/ILIAS/UI/src/templates/default/Player/tpl.audio.html b/components/ILIAS/UI/src/templates/default/Player/tpl.audio.html index 3efe80c1c2e9..6302eccc951f 100755 --- a/components/ILIAS/UI/src/templates/default/Player/tpl.audio.html +++ b/components/ILIAS/UI/src/templates/default/Player/tpl.audio.html @@ -1,5 +1,5 @@
- + {BUTTON_AND_MODAL} diff --git a/components/ILIAS/UI/src/templates/default/Player/tpl.video.html b/components/ILIAS/UI/src/templates/default/Player/tpl.video.html index c8c5253e69b0..8e7eb44b465b 100755 --- a/components/ILIAS/UI/src/templates/default/Player/tpl.video.html +++ b/components/ILIAS/UI/src/templates/default/Player/tpl.video.html @@ -1,5 +1,5 @@
-
\ No newline at end of file diff --git a/components/ILIAS/UI/src/templates/default/Player/tpl.video_vimeo.html b/components/ILIAS/UI/src/templates/default/Player/tpl.video_vimeo.html new file mode 100755 index 000000000000..17b6bcb7ed95 --- /dev/null +++ b/components/ILIAS/UI/src/templates/default/Player/tpl.video_vimeo.html @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/components/ILIAS/UI/src/templates/default/Player/tpl.video_youtube.html b/components/ILIAS/UI/src/templates/default/Player/tpl.video_youtube.html new file mode 100755 index 000000000000..17b6bcb7ed95 --- /dev/null +++ b/components/ILIAS/UI/src/templates/default/Player/tpl.video_youtube.html @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/components/ILIAS/UI/tests/Component/Item/ItemTest.php b/components/ILIAS/UI/tests/Component/Item/ItemTest.php index c052b250c12b..5ee3546560a5 100755 --- a/components/ILIAS/UI/tests/Component/Item/ItemTest.php +++ b/components/ILIAS/UI/tests/Component/Item/ItemTest.php @@ -638,11 +638,12 @@ public function testRenderAudioPlayer(): void $c = $f->standard("title")->withAudioPlayer($audio); $html = $r->render($c); + $expected = <<

title

- +
EOT; diff --git a/components/ILIAS/UI/tests/Component/Player/PlayerAudioTest.php b/components/ILIAS/UI/tests/Component/Player/PlayerAudioTest.php index 6e27779b4cb1..14005b746212 100755 --- a/components/ILIAS/UI/tests/Component/Player/PlayerAudioTest.php +++ b/components/ILIAS/UI/tests/Component/Player/PlayerAudioTest.php @@ -100,7 +100,7 @@ public function testRenderAudio(): void $expected = << - + EOT; $this->assertHTMLEquals( diff --git a/components/ILIAS/UI/tests/Component/Player/PlayerVideoTest.php b/components/ILIAS/UI/tests/Component/Player/PlayerVideoTest.php index b684c4452c44..c820b69f3313 100755 --- a/components/ILIAS/UI/tests/Component/Player/PlayerVideoTest.php +++ b/components/ILIAS/UI/tests/Component/Player/PlayerVideoTest.php @@ -108,7 +108,7 @@ public function testRenderVideo(): void $html = $r->render($video); $expected = << -