]> _ Git - fluidbook_tools.git/commitdiff
wip #5741 @0:20
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Feb 2023 16:02:14 +0000 (17:02 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Feb 2023 16:02:14 +0000 (17:02 +0100)
src/Links/WebVideoLink.php
src/Links/WebVideoPopupLink.php

index 240fbc5efc9b4ac8ed691da7a2f82fa13d07c0dc..0c6be179966232db8ab9ad8ce5920e077c0b0a18 100644 (file)
@@ -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 '<iframe width="' . $width . '" height="' . $height . '" src="' . self::getEmbedURL($link) . '" frameborder="0" allowfullscreen></iframe>';
     }
 
-    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);
index 9323c03e1b1abab60446ddd09a03e3dba58d89a7..0f16f6086d041b92fab450ebf8bc8317b6370a38 100644 (file)
@@ -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;