From ab3c77fd56da82325285784d63aab89119435b92 Mon Sep 17 00:00:00 2001 From: st-anton Date: Mon, 2 Jan 2023 18:18:02 +0100 Subject: [PATCH] use html5 instead of jwplayer for direct link; omit downloading pwplayer code --- admin/helpers/html/fancybox.php | 2 +- site/src/Helper/CWMMedia.php | 67 +++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/admin/helpers/html/fancybox.php b/admin/helpers/html/fancybox.php index 6ae9fd720..ae4362cc2 100644 --- a/admin/helpers/html/fancybox.php +++ b/admin/helpers/html/fancybox.php @@ -45,7 +45,7 @@ public static function framework($option = false, $mouseweel = false) } HTMLHelper::_('jquery.framework'); - HTMLHelper::_('jwplayer.framework'); + // HTMLHelper::_('jwplayer.framework'); HTMLHelper::script('media/com_proclaim/fancybox/jquery.fancybox.min.js'); HTMLHelper::script('media/com_proclaim/js/fancybox.min.js'); diff --git a/site/src/Helper/CWMMedia.php b/site/src/Helper/CWMMedia.php index 17a327d4d..37489af98 100644 --- a/site/src/Helper/CWMMedia.php +++ b/site/src/Helper/CWMMedia.php @@ -661,6 +661,15 @@ public function getPlayerCode(Registry $params, object $player, string $image, o switch ($player->type) { + case 1: // Popup window + $playercode = "toObject()->player . + "&view=cwmpopup&t=" . $template . "&mediaid=" . $media->id . "&tmpl=component', 'newwindow','width=" . + $player->playerwidth . ",height=" . $player->playerheight . "'); return false\" class=\"jbsmplayerlink\">" + . $image . ""; + break; + case 2: // New window - popup code added here because new window code does not work (Tom 10-12-2022) $return = base64_encode($path); $playercode = 'toObject()->player . - "&view=cwmpopup&t=" . $template . "&mediaid=" . $media->id . "&tmpl=component', 'newwindow','width=" . - $player->playerwidth . ",height=" . $player->playerheight . "'); return false\" class=\"jbsmplayerlink\">" - . $image . ""; - break; } return $playercode; - case 7: + case 7: // legacy internal player case 1: // Internal $playercode = ''; switch ($player->type) { - case 3: // Squeezebox view - - return $this->rendersb($media, $params, $player, $image, $path); + case 1: // Popup + // Add space for popup window + $diff = $params->get('player_width') - $params->get('playerwidth'); + $player->playerwidth += abs($diff) + 10; + $player->playerheight += $params->get('popupmargin', '50'); + $playercode = "player + . "&view=cwmpopup&t=" . $template . "&mediaid=" . $media->id . "&tmpl=component', 'newwindow', 'width=" + . $player->playerwidth . ", height=" . + $player->playerheight . "'); return false\" class=\"jbsmplayerlink\">" . $image . ""; break; case 2: // Inline @@ -730,17 +738,9 @@ public function getPlayerCode(Registry $params, object $player, string $image, o break; - case 1: // Popup - // Add space for popup window - $diff = $params->get('player_width') - $params->get('playerwidth'); - $player->playerwidth += abs($diff) + 10; - $player->playerheight += $params->get('popupmargin', '50'); - $playercode = "player - . "&view=cwmpopup&t=" . $template . "&mediaid=" . $media->id . "&tmpl=component', 'newwindow', 'width=" - . $player->playerwidth . ", height=" . - $player->playerheight . "'); return false\" class=\"jbsmplayerlink\">" . $image . ""; + case 3: // Squeezebox view + + return $this->rendersb($media, $params, $player, $image, $path); break; } @@ -763,6 +763,8 @@ public function getPlayerCode(Registry $params, object $player, string $image, o $mediacode = $this->getAVmediacode($media->mediacode, $media); $playercode = HtmlHelper::_('content.prepare', $mediacode); break; + + // no squeezebox available } return $playercode; @@ -804,7 +806,7 @@ public function rendersb(object $media, Registry $params, object $player, string { HtmlHelper::_('fancybox.framework', true, true); - if ($player->player === '7' && !$direct) + if (($player->player === '7' && !$direct) || (preg_match('/audio/', $media->params->get('mime_type')) === 1 && $direct)) { $player->playerheight = '40'; } @@ -820,12 +822,27 @@ public function rendersb(object $media, Registry $params, object $player, string if (preg_match('(youtube.com|youtu.be|vimeo.com)', $path) === 1) { + HTMLHelper::_('jwplayer.framework'); + return 'get('autostart', false) . '", "controls" : "' . (int) $params->get('controls') . '", "caption" : "' . $media->studytitle . ' - ' . $media->teachername . '"}\' href="javascript:;">' . $image . ''; } + if ($direct) + { + // use data-type=video for both video and audio, this is a suggestion of fancyapps. See issue 2244 in github project fancybox + return 'get('controls') . + '", "caption" : "' . $media->studytitle . ' - ' . $media->teachername . + '"}\' href="javascript:;">' . $image . ''; + } + + HTMLHelper::_('jwplayer.framework'); + return '