diff --git a/components/ILIAS/UI/src/Component/Player/Video.php b/components/ILIAS/UI/src/Component/Player/Video.php index e30e05f9fc21..b6d0469f20ab 100755 --- a/components/ILIAS/UI/src/Component/Player/Video.php +++ b/components/ILIAS/UI/src/Component/Player/Video.php @@ -1,7 +1,5 @@ + */ + public function getSubtitleLabels(): array; + /** * Set initially shown poster image * @param string $poster relative web root path of an image file, URL of an external image resource (png,jpg,svg,gif) diff --git a/components/ILIAS/UI/src/Implementation/Component/Player/Renderer.php b/components/ILIAS/UI/src/Implementation/Component/Player/Renderer.php index 9489d4788a3e..3f4e876106a3 100755 --- a/components/ILIAS/UI/src/Implementation/Component/Player/Renderer.php +++ b/components/ILIAS/UI/src/Implementation/Component/Player/Renderer.php @@ -128,10 +128,12 @@ public function renderNative( $id = $this->bindJavaScript($component); + $labels = $component->getSubtitleLabels(); foreach ($component->getSubtitleFiles() as $lang_key => $file) { $tpl->setCurrentBlock("track"); $tpl->setVariable("TRACK_SOURCE", $file); $tpl->setVariable("TRACK_LANG", $lang_key); + $tpl->setVariable("TRACK_LABEL", $labels[$lang_key] ?? ""); $tpl->parseCurrentBlock(); } diff --git a/components/ILIAS/UI/src/Implementation/Component/Player/Video.php b/components/ILIAS/UI/src/Implementation/Component/Player/Video.php index 51b678f8d96a..ed5db72b62ea 100755 --- a/components/ILIAS/UI/src/Implementation/Component/Player/Video.php +++ b/components/ILIAS/UI/src/Implementation/Component/Player/Video.php @@ -1,7 +1,5 @@ subtitle_files[$lang_key] = $subtitle_file; + $clone->subtitle_labels[$lang_key] = $label; return $clone; } @@ -47,6 +49,11 @@ public function getSubtitleFiles(): array return $this->subtitle_files; } + public function getSubtitleLabels(): array + { + return $this->subtitle_labels; + } + public function withPoster(string $poster): C\Player\Video { $clone = clone $this; diff --git a/components/ILIAS/UI/src/examples/Player/Video/video_mp4.php b/components/ILIAS/UI/src/examples/Player/Video/video_mp4.php index cc5e083ff7fb..f410dd586f75 100755 --- a/components/ILIAS/UI/src/examples/Player/Video/video_mp4.php +++ b/components/ILIAS/UI/src/examples/Player/Video/video_mp4.php @@ -11,9 +11,9 @@ * * expected output: > * ILIAS shows a rendered video player with a start screen. On the left side you will see a Start/Stop symbol, - * followed by a time bar and on the right side a symbol for subtitles (CC), volume control and for the the full screen. + * followed by a time bar and on the right side a symbol for subtitles (CC) (depends on browser), volume control and for the the full screen. * A big start symbol is shown in the middle of the start screen. While hovering over the subtitles symbol a list of all - * available languages appears. If a language gets selected you can find the text at the bottom of the full screen. + * available languages appears. If a language gets selected you can find the text above the time bar. * * In addition following functions have to be tested: * - The video starts playing if clicking the start/stop symbol in the middle of the image. The video stops after another click. @@ -28,8 +28,8 @@ function video_mp4(): string $f = $DIC->ui()->factory(); $video = $f->player()->video("https://files.ilias.de/ks/ILIAS-Video.mp4"); - $video = $video->withAdditionalSubtitleFile("en", "./assets/ui-examples/misc/subtitles_en.vtt"); - $video = $video->withAdditionalSubtitleFile("de", "./assets/ui-examples/misc/subtitles_de.vtt"); + $video = $video->withAdditionalSubtitleFile("en", "./assets/ui-examples/misc/subtitles_en.vtt", "English"); + $video = $video->withAdditionalSubtitleFile("de", "./assets/ui-examples/misc/subtitles_de.vtt", "Deutsch"); return $renderer->render($video); } 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 55ce14419688..09b53cd9b4b1 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/tests/Component/Player/PlayerVideoTest.php b/components/ILIAS/UI/tests/Component/Player/PlayerVideoTest.php index d97c8a61b2c9..569482b5571e 100755 --- a/components/ILIAS/UI/tests/Component/Player/PlayerVideoTest.php +++ b/components/ILIAS/UI/tests/Component/Player/PlayerVideoTest.php @@ -93,9 +93,10 @@ public function testGetTitleGetSubtitleFile(): void { $f = $this->getFactory(); - $video = $f->video("/foo")->withAdditionalSubtitleFile("en", "subtitles.vtt"); + $video = $f->video("/foo")->withAdditionalSubtitleFile("en", "subtitles.vtt", "English"); $this->assertEquals(["en" => "subtitles.vtt"], $video->getSubtitleFiles()); + $this->assertEquals(["en" => "English"], $video->getSubtitleLabels()); } public function testRenderVideo(): void @@ -143,13 +144,13 @@ public function testRenderWithSubtitles(): void $f = $this->getFactory(); $r = $this->getDefaultRenderer(); - $video = $f->video("/foo")->withAdditionalSubtitleFile("en", "subtitles.vtt"); + $video = $f->video("/foo")->withAdditionalSubtitleFile("en", "subtitles.vtt", "English"); $html = $r->render($video); $expected = << EOT;