Merge pull request #572 from im-mi/video-playback-options

Added video playback options for autoplay and loop
This commit is contained in:
Shish 2016-08-20 14:57:16 +01:00 committed by GitHub
commit 98254ef5bd
2 changed files with 20 additions and 3 deletions

View file

@ -2,7 +2,7 @@
/*
* Name: Handle Video
* Author: velocity37 <velocity37@gmail.com>
* Modified By: Shish <webmaster@shishnet.org>, jgen <jeffgenovy@gmail.com>
* Modified By: Shish <webmaster@shishnet.org>, jgen <jeffgenovy@gmail.com>, im-mi <im.mi.mail.mi@gmail.com>
* License: GPLv2
* Description: Handle FLV, MP4, OGV and WEBM video files.
* Documentation:
@ -42,6 +42,9 @@ class VideoFileHandler extends DataHandlerExtension {
$config->set_int("ext_handle_video_version", 1);
log_info("pools", "extension installed");
}
$config->set_default_bool('video_playback_autoplay', TRUE);
$config->set_default_bool('video_playback_loop', TRUE);
}
public function onSetupBuilding(SetupBuildingEvent $event) {
@ -67,6 +70,12 @@ class VideoFileHandler extends DataHandlerExtension {
$sb->add_bool_option("video_thumb_ignore_aspect_ratio", "Ignore aspect ratio when creating thumbnails: ");
$event->panel->add_block($sb);
$sb = new SetupBlock("Video Playback Options");
$sb->add_bool_option("video_playback_autoplay", "Autoplay: ");
$sb->add_label("<br>");
$sb->add_bool_option("video_playback_loop", "Loop: ");
$event->panel->add_block($sb);
}
/**

View file

@ -2,10 +2,13 @@
class VideoFileHandlerTheme extends Themelet {
public function display_image(Page $page, Image $image) {
global $config;
$ilink = $image->get_image_link();
$thumb_url = make_http($image->get_thumb_link()); //used as fallback image
$ext = strtolower($image->get_ext());
$full_url = make_http($ilink);
$autoplay = $config->get_bool("video_playback_autoplay");
$loop = $config->get_bool("video_playback_loop");
$html = "Video not playing? <a href='" . $image->parse_link_template(make_link('image/$id/$id%20-%20$tags.$ext')) . "'>Click here</a> to download the file.<br/>";
@ -25,7 +28,12 @@ class VideoFileHandlerTheme extends Themelet {
<param name=\"allowFullScreen\" value=\"true\" />
<param name=\"wmode\" value=\"opaque\" />
<param name=\"flashVars\" value=\"controls=true&autoplay=true&poster={$thumb_url}&file={$full_url}\" />
<param name=\"flashVars\" value=\""
. "controls=true"
. "&autoplay=" . ($autoplay ? 'true' : 'false')
. "&poster={$thumb_url}"
. "&file={$full_url}"
. "&loop=" . ($loop ? 'true' : 'false') . "\" />
<img src=\"{$thumb_url}\" />
</object>";
@ -34,7 +42,7 @@ class VideoFileHandlerTheme extends Themelet {
$html .= $html_fallback;
} else {
$html .= "
<video controls autoplay width=\"100%\">
<video controls " . ($autoplay ? 'autoplay' : '') . " width=\"100%\" " . ($loop ? 'loop' : '') . ">
<source src='{$ilink}' type='{$supportedExts[$ext]}'>
<!-- If browser doesn't support filetype, fallback to flash -->