Added mute option to video handler

This commit is contained in:
Matthew Barbour 2020-06-24 08:14:24 -05:00 committed by Shish
parent 9b5d963aa3
commit 846d978a52
2 changed files with 11 additions and 6 deletions

View file

@ -4,6 +4,7 @@ abstract class VideoFileHandlerConfig
{
public const PLAYBACK_AUTOPLAY = "video_playback_autoplay";
public const PLAYBACK_LOOP = "video_playback_loop";
public const PLAYBACK_MUTE = "video_playback_mute";
public const ENABLED_FORMATS = "video_enabled_formats";
}
@ -27,6 +28,7 @@ class VideoFileHandler extends DataHandlerExtension
$config->set_default_bool(VideoFileHandlerConfig::PLAYBACK_AUTOPLAY, true);
$config->set_default_bool(VideoFileHandlerConfig::PLAYBACK_LOOP, true);
$config->set_default_bool(VideoFileHandlerConfig::PLAYBACK_MUTE, false);
$config->set_default_array(
VideoFileHandlerConfig::ENABLED_FORMATS,
[MIME_TYPE_FLASH_VIDEO, MIME_TYPE_MP4_VIDEO, MIME_TYPE_OGG_VIDEO, MIME_TYPE_WEBM]
@ -45,11 +47,12 @@ class VideoFileHandler extends DataHandlerExtension
public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = new SetupBlock("Video Options");
$sb->add_bool_option(VideoFileHandlerConfig::PLAYBACK_AUTOPLAY, "Autoplay: ");
$sb->add_label("<br>");
$sb->add_bool_option(VideoFileHandlerConfig::PLAYBACK_LOOP, "Loop: ");
$sb->add_label("<br>Enabled Formats:");
$sb->add_multichoice_option(VideoFileHandlerConfig::ENABLED_FORMATS, $this->get_options());
$sb->start_table();
$sb->add_bool_option(VideoFileHandlerConfig::PLAYBACK_AUTOPLAY, "Autoplay", true);
$sb->add_bool_option(VideoFileHandlerConfig::PLAYBACK_LOOP, "Loop", true);
$sb->add_bool_option(VideoFileHandlerConfig::PLAYBACK_MUTE, "Mute", true);
$sb->add_multichoice_option(VideoFileHandlerConfig::ENABLED_FORMATS, $this->get_options(), "Enabled Formats", true);
$sb->end_table();
$event->panel->add_block($sb);
}

View file

@ -11,6 +11,7 @@ class VideoFileHandlerTheme extends Themelet
$full_url = make_http($ilink);
$autoplay = $config->get_bool(VideoFileHandlerConfig::PLAYBACK_AUTOPLAY);
$loop = $config->get_bool(VideoFileHandlerConfig::PLAYBACK_LOOP);
$mute = $config->get_bool(VideoFileHandlerConfig::PLAYBACK_MUTE);
$player = make_link('vendor/bower-asset/mediaelement/build/flashmediaelement.swf');
$width="auto";
@ -56,9 +57,10 @@ class VideoFileHandlerTheme extends Themelet
} else {
$autoplay = ($autoplay ? ' autoplay' : '');
$loop = ($loop ? ' loop' : '');
$mute = ($mute ? ' muted' : '');
$html .= "
<video controls class='shm-main-image' id='main_image' alt='main image' poster='$thumb_url' {$autoplay} {$loop}
<video controls class='shm-main-image' id='main_image' alt='main image' poster='$thumb_url' {$autoplay} {$loop} {$mute}
style='height: $height; width: $width; max-width: 100%'>
<source src='{$ilink}' type='{$mime}'>