From bbcd931ec267ee019d89a2de1db36372ef626dee Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 16 Feb 2023 17:02:14 +0100 Subject: [PATCH] wip #5741 @0:20 --- src/Links/WebVideoLink.php | 29 ++++++++++++++--------------- src/Links/WebVideoPopupLink.php | 6 +++++- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/Links/WebVideoLink.php b/src/Links/WebVideoLink.php index 240fbc5..0c6be17 100644 --- a/src/Links/WebVideoLink.php +++ b/src/Links/WebVideoLink.php @@ -2,11 +2,9 @@ namespace Fluidbook\Tools\Links; -class WebVideoLink extends VideoLink -{ +class WebVideoLink extends VideoLink { - public static function getVideoAttributes($data, $w = null, $h = null, $compiler = null) - { + public static function getVideoAttributes($data, $w = null, $h = null, $compiler = null) { $attributes = parent::getVideoAttributes($data, $w, $h, $compiler); // Since the admin interface doesn't offer options for setting controls or sound, we will set some defaults here @@ -20,12 +18,12 @@ class WebVideoLink extends VideoLink /** * @throws \JsonException */ - public static function getVideoSetup($data, $compiler) - { + public static function getVideoSetup($data, $compiler) { static::addVideoJS($compiler); // Ensure videoJS core is included first switch ($data->video_service) { case 0: // YouTube + case 'youtube': $compiler->addJsLib('videojs-youtube', 'js/libs/videojs/Youtube.js'); // $compiler->addJs('https://rawgit.com/videojs/videojs-youtube/master/dist/Youtube.js'); $setup = [ @@ -40,6 +38,7 @@ class WebVideoLink extends VideoLink ]; break; case 1: // Dailymotion + case 'dailymotion': // Todo: add local version of script... // Note: this plugin doesn't seem to work currently so it is not included //$compiler->addJs('https://rawgit.com/benjipott/video.js-dailymotion/master/dist-test/videojs-dailymotion.js'); @@ -53,6 +52,7 @@ class WebVideoLink extends VideoLink ]; break; case 2: // Vimeo + case 'vimeo': // Todo: add local version of script... // Note: Vimeo plugin doesn't seem to be working currently - might need updates to work with latest VideoJS module //$compiler->addJs('https://rawgit.com/videojs/videojs-vimeo/master/dist/videojs-vimeo.min.js'); @@ -74,8 +74,7 @@ class WebVideoLink extends VideoLink } - public function getHTMLContent() - { + public function getHTMLContent() { if ($this->video_service != 0) { return self::getEmbed($this); } @@ -86,8 +85,7 @@ class WebVideoLink extends VideoLink return self::makeVideoTag($this, $w, $h, $this->compiler); } - public static function getEmbed($link, $width = null, $height = null) - { + public static function getEmbed($link, $width = null, $height = null) { if (null === $width) { $width = $link->width; } @@ -97,14 +95,16 @@ class WebVideoLink extends VideoLink return ''; } - public static function getEmbedURL($data) - { + public static function getEmbedURL($data) { switch ($data->video_service) { case 0: + case 'youtube': return 'https://www.youtube.com/embed/' . $data->to . '?html5=1'; case 1: + case 'dailymotion': return 'https://www.dailymotion.com/embed/video/' . $data->to; case 2: + case 'vimeo': return 'https://player.vimeo.com/video/' . $data->to; case 3: default: @@ -112,9 +112,8 @@ class WebVideoLink extends VideoLink } } - public static function makeVideoTag($link, $width=null, $height=null, $compiler = null) - { - if ($link->video_service == 0) { + public static function makeVideoTag($link, $width = null, $height = null, $compiler = null) { + if ($link->video_service == 0 || $link->video_service == 'youtube') { return parent::makeVideoTag($link, $width, $height, $compiler); } return self::getEmbed($link); diff --git a/src/Links/WebVideoPopupLink.php b/src/Links/WebVideoPopupLink.php index 9323c03..0f16f60 100644 --- a/src/Links/WebVideoPopupLink.php +++ b/src/Links/WebVideoPopupLink.php @@ -8,13 +8,17 @@ class WebVideoPopupLink extends VideoPopupLink public function getURL() { switch ($this->video_service) { - case 0: // Dailymotion + case 0: // Youtube + case 'youtube': return '#/webvideo/youtube/' . $this->to; case 1: // Dailymotion + case 'dailymotion': return '#/webvideo/dailymotion/' . $this->to; case 2: // Vimeo + case 'vimeo': return '#/webvideo/vimeo/' . $this->to; case 3: // Brightcove + case 'brightcove': return '#/webvideo/brightcove/' . md5($this->to); default: return '#/video/' . $this->to; -- 2.39.5