Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use html5 instead of jwplayer for direct link; omit downloading pwplayer code #920

Draft
wants to merge 4 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/helpers/html/fancybox.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,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');

Expand Down
67 changes: 42 additions & 25 deletions site/src/Helper/CWMMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,15 @@ public function getPlayerCode(Registry $params, object $player, string $image, o

switch ($player->type)
{
case 1: // Popup window
$playercode = "<a style='color: #5F5A58;' href=\"javascript:;\"" .
" onclick=\"window.open('index.php?option=com_proclaim&amp;player="
. $params->toObject()->player .
"&amp;view=cwmpopup&amp;t=" . $template . "&amp;mediaid=" . $media->id . "&amp;tmpl=component', 'newwindow','width=" .
$player->playerwidth . ",height=" . $player->playerheight . "'); return false\" class=\"jbsmplayerlink\">"
. $image . "</a>";
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 = '<a href="javascript:;" onclick="window.open(\'index.php?option=com_proclaim&amp;' .
Expand All @@ -670,28 +679,27 @@ public function getPlayerCode(Registry $params, object $player, string $image, o
case 3: // Squeezebox view
return $this->rendersb($media, $params, $player, $image, $path, true);
break;

case 1: // Popup window
$playercode = "<a style='color: #5F5A58;' href=\"javascript:;\"" .
" onclick=\"window.open('index.php?option=com_proclaim&amp;player="
. $params->toObject()->player .
"&amp;view=cwmpopup&amp;t=" . $template . "&amp;mediaid=" . $media->id . "&amp;tmpl=component', 'newwindow','width=" .
$player->playerwidth . ",height=" . $player->playerheight . "'); return false\" class=\"jbsmplayerlink\">"
. $image . "</a>";
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 = "<a style='color: #5F5A58;' href=\"javascript:;\"" .
" onclick=\"window.open('index.php?option=com_proclaim&amp;player="
. $player->player
. "&amp;view=cwmpopup&amp;t=" . $template . "&amp;mediaid=" . $media->id . "&amp;tmpl=component', 'newwindow', 'width="
. $player->playerwidth . ", height=" .
$player->playerheight . "'); return false\" class=\"jbsmplayerlink\">" . $image . "</a>";
break;

case 2: // Inline
Expand Down Expand Up @@ -728,17 +736,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 = "<a style='color: #5F5A58;' href=\"javascript:;\"" .
" onclick=\"window.open('index.php?option=com_proclaim&amp;player="
. $player->player
. "&amp;view=cwmpopup&amp;t=" . $template . "&amp;mediaid=" . $media->id . "&amp;tmpl=component', 'newwindow', 'width="
. $player->playerwidth . ", height=" .
$player->playerheight . "'); return false\" class=\"jbsmplayerlink\">" . $image . "</a>";
case 3: // Squeezebox view

return $this->rendersb($media, $params, $player, $image, $path);
break;
}

Expand All @@ -761,6 +761,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;
Expand Down Expand Up @@ -802,7 +804,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';
}
Expand All @@ -818,12 +820,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 '<a data-fancybox class="playhit" data-id="' . $media->id . '" data-options=\'{"src" : "' . $path . '", "autoplay" : "' .
(int) $params->get('autostart', false) . '", "controls" : "' . (int) $params->get('controls') .
'", "caption" : "' . $media->studytitle . ' - ' .
$media->teachername . '"}\' href="javascript:;">' . $image . '</a>';
}

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 '<a data-fancybox data-type="video" class="playhit" data-id="' . $media->id .
'" data-width="' . $player->playerwidth . '" data-height="' . $player->playerheight .
'" data-options=\'{"src" : "' . $path .
'", "controls" : "' . (int) $params->get('controls') .
'", "caption" : "' . $media->studytitle . ' - ' . $media->teachername .
'"}\' href="javascript:;">' . $image . '</a>';
}

HTMLHelper::_('jwplayer.framework');

return '<a data-src="' . $path . '" data-id="' . $media->id . '" id="linkmedia' . $media->id . '" title="' . $params->get('filename') .
'" class="fancybox fancybox_jwplayer hitplay" potext="' . $popout . '" ptype="' . $player->player .
'" pwidth="' . $player->playerwidth . '" pheight="' .
Expand Down