diff --git a/boot.php b/boot.php index 7d27219..7886d24 100644 --- a/boot.php +++ b/boot.php @@ -1,4 +1,5 @@ getAssetsUrl('vidstack.css')); rex_view::addCssFile($vs->getAssetsUrl('vidstack_helper.css')); rex_view::addJsFile($vs->getAssetsUrl('vidstack.js')); rex_view::addJsFile($vs->getAssetsUrl('vidstack_helper.js')); - # rex_extension::register('MEDIA_DETAIL_SIDEBAR', '\FriendsOfRedaxo\VidStack\vidstack_mediapool::show_sidebar'); + rex_extension::register('MEDIA_DETAIL_SIDEBAR', [Video::class, 'show_sidebar']); } - */ diff --git a/lib/video.php b/lib/video.php index d4b5ed8..1441cef 100644 --- a/lib/video.php +++ b/lib/video.php @@ -2,6 +2,7 @@ namespace FriendsOfRedaxo\VidStack; +use pathinfo; use rex_escape; use rex_path; use rex_url; @@ -204,4 +205,21 @@ public static function parseOembedTags(string $content): string return $video->generateFull(); }, $content); } + + public static function show_sidebar(\rex_extension_point $ep): string + { + $params = $ep->getParams(); + $file = $params['filename']; + + if (in_array(pathinfo($file, PATHINFO_EXTENSION), ['mp4', 'm4v', 'mov'])) { + $video = new self($file); + $video->setAttributes([ + 'crossorigin' => '', + 'playsinline' => true, + 'controls' => true + ]); + return $video->generate(); + } + return ''; // Return an empty string if the condition is not met + } }