diff --git a/framework/elements/video/video.php b/framework/elements/video/video.php new file mode 100644 index 00000000..d1e20271 --- /dev/null +++ b/framework/elements/video/video.php @@ -0,0 +1,134 @@ +get('video_type', 'url'); +$url = $params->get('url', ''); +$mp4_video = $params->get('mp4_video', ''); +$ogv_video = $params->get('ogv_video', ''); + +$no_cookie = $params->get('no_cookie', 0); +$show_rel_video = $params->get('show_rel_video', 0); +$youtube_shorts = $params->get('youtube_shorts', 0); +$aspect_ratio = $params->get('aspect_ratio', '16x9'); + +$vimeo_show_author = 'byline=' . $params->get('vimeo_show_author', 0); +$vimeo_mute_video = 'muted=' . $params->get('vimeo_mute_video', 1); +$vimeo_show_author_profile = 'portrait=' . $params->get('vimeo_show_author_profile', 0); +$vimeo_show_video_title = 'title=' . $params->get('vimeo_show_video_title', 0); + +$show_control = $params->get('show_control', 1); +$video_loop = $params->get('video_loop', 1); +$video_mute = $params->get('video_mute', 1); +$autoplay_video = $params->get('autoplay_video', 1); +$video_poster = $params->get('video_poster', ''); +if ($video_poster) { + $video_poster = Uri::base(true) . '/' . Media::getPath() . '/' . $video_poster; +} +$video_title = ""; + +if (!(!empty($mp4_video) && (strpos($mp4_video, "http://") !== false || strpos($mp4_video, "https://") !== false))) +{ + $mp4_video = Uri::base(true) . '/' . Media::getPath() . '/' . $mp4_video; +} + +if (!(!empty($ogv_video) && (strpos($ogv_video, "http://") !== false || strpos($ogv_video, "https://") !== false))) +{ + $ogv_video = Uri::base(true) . '/' . Media::getPath() . '/' . $ogv_video; +} + +if ($url) +{ + $video = parse_url($url); + + $youtube_no_cookie = $no_cookie ? '-nocookie' : ''; + + if(array_key_exists('host', $video)) { + switch ($video['host']) + { + case 'youtu.be': + $id = trim($video['path'], '/'); + $src = '//www.youtube' . $youtube_no_cookie . '.com/embed/' . $id . '?iv_load_policy=3' . $show_rel_video; + $video_title = $params->get('video_title', 'Youtube Video'); + break; + + case 'www.youtube.com': + case 'youtube.com': + $query = []; + $playlist_id = null; + if(array_key_exists('query', $video)) { + parse_str($video['query'], $query); + } + + if($video['path'] === '/playlist') { + if (preg_match('/\blist=([^&]+)/', $video['query'], $matches)) { + $playlist_id = $matches[1]; + } + } + + $src = ''; + + if($playlist_id) { + $src = '//www.youtube.com/embed/?listType=playlist&list=' . $playlist_id; + } else { + $id = ($youtube_shorts) ? str_replace('/shorts/', "", $video['path']) : $query['v']; + $src = '//www.youtube' . $youtube_no_cookie . '.com/embed/' . $id . '?iv_load_policy=3' . $show_rel_video; + } + + $video_title = $params->get('video_title', 'Youtube Video'); + break; + + case 'vimeo.com': + case 'www.vimeo.com': + case 'player.vimeo.com': + $initialSrc = $url; + + if($video['host'] !== 'player.vimeo.com') { + $id = trim($video['path'], '/'); + $initialSrc = "//player.vimeo.com/video/{$id}"; + } + + $src = $initialSrc . '?' . implode('&', array($vimeo_mute_video, $vimeo_show_author, $vimeo_show_author_profile, $vimeo_show_video_title, 'autoplay='. $autoplay_video, 'loop='. $video_loop, 'controls='. $show_control)); + break; + } + } +} + +if ($video_type == 'url') +{ + echo '
'; + echo ''; + echo '
'; +} +else +{ + if ($mp4_video || $ogv_video) + { + echo '
'; + echo ''; + echo '
'; + } +} \ No newline at end of file diff --git a/framework/elements/video/video.xml b/framework/elements/video/video.xml new file mode 100644 index 00000000..dea87619 --- /dev/null +++ b/framework/elements/video/video.xml @@ -0,0 +1,51 @@ + + + ASTROID_WIDGET_VIDEO_LABEL + ASTROID_WIDGET_VIDEO_LABEL + fa-solid fa-video + ASTROID_ELEMENT_CATEGORY_MEDIA + widget +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
+
+
diff --git a/framework/elements/video_button/video_button.xml b/framework/elements/video_button/video_button.xml index d6759251..2c2962ad 100644 --- a/framework/elements/video_button/video_button.xml +++ b/framework/elements/video_button/video_button.xml @@ -2,14 +2,14 @@ ASTROID_WIDGET_VIDEO_BUTTON_LABEL ASTROID_WIDGET_VIDEO_BUTTON_DESC - fa-solid fa-video + fa-solid fa-play ASTROID_ELEMENT_CATEGORY_MEDIA widget
- + diff --git a/language/en-GB/en-GB.astroid.ini b/language/en-GB/en-GB.astroid.ini index ddaa7db8..2c4139b2 100644 --- a/language/en-GB/en-GB.astroid.ini +++ b/language/en-GB/en-GB.astroid.ini @@ -1414,6 +1414,27 @@ ASTROID_WIDGET_VIDEO_BUTTON_URL_LABEL="Video Button URL" ASTROID_WIDGET_RIPPLE_COLOR_LABEL="Ripple Color" ASTROID_WIDGET_BUTTON_SIZE_LABEL="Button Size" +; Video Widget +ASTROID_WIDGET_VIDEO_LABEL="Video" +ASTROID_WIDGET_VIDEO_TYPE="Video Type" +ASTROID_WIDGET_VIDEO_LOCAL="Local Video" +ASTROID_WIDGET_VIDEO_URL="Youtube/Vimeo" +ASTROID_WIDGET_VIDEO_TITLE="Video Title" +ASTROID_WIDGET_VIDEO_MP4="MP4 Video" +ASTROID_WIDGET_VIDEO_OGV="OGV Video" +ASTROID_WIDGET_SHOW_RELATED_VIDEOS="Show Related Videos" +ASTROID_WIDGET_NO_COOKIE="Turn Off Youtube Cookie" +ASTROID_WIDGET_ADD_YOUTUBE_SHORTS="Add YouTube Shorts" +ASTROID_WIDGET_YOUTUBE_ASPECT_RATIO="Aspect Ratio" +ASTROID_WIDGET_VIMEO_SHOW_AUTHOR="Show Author (Vimeo)" +ASTROID_WIDGET_VIMEO_SHOW_AUTHOR_PROFILE="Show Author’s Profile Image (Vimeo)" +ASTROID_WIDGET_VIMEO_MUTE_VIDEO="Mute Video (Vimeo)" +ASTROID_WIDGET_VIMEO_SHOW_TITLE="Show Video Title (Vimeo)" +ASTROID_WIDGET_VIDEO_SHOW_CONTROL="Show Control" +ASTROID_WIDGET_VIDEO_VIDEO_LOOP="Video Loop" +ASTROID_WIDGET_VIDEO_VIDEO_MUTE="Video Mute" +ASTROID_WIDGET_VIDEO_POSTER="Video Poster" + ; Article Widget ASTROID_WIDGET_ARTICLES_LABEL="Articles" ASTROID_WIDGET_ARTICLES_DESC="Define different styles for Articles"