From aedb578459c9ca79bca5ec1bda9e252c09e1ec2a Mon Sep 17 00:00:00 2001 From: vargenau Date: Wed, 25 Mar 2015 11:32:00 +0000 Subject: [PATCH] Improve Video plugin git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@9629 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/BlockParser.php | 7 ++++++- lib/InlineParser.php | 7 ++++++- lib/plugin/Video.php | 19 ++++++++++++++++--- lib/stdlib.php | 6 ++++-- pgsrc/Help%2FVideoPlugin | 19 +++++++++++++------ 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/lib/BlockParser.php b/lib/BlockParser.php index 9a870330a..3e681d5bc 100644 --- a/lib/BlockParser.php +++ b/lib/BlockParser.php @@ -1193,7 +1193,12 @@ class Block_template_plugin extends Block_pre // It's a video if (is_video($imagename)) { - $pi = '<' . '?plugin Video file="' . $pi . '" ?>'; + if ((strpos($imagename, 'http://') === 0) + || (strpos($imagename, 'https://') === 0)) { + $pi = '<' . '?plugin Video url="' . $pi . '" ?>'; + } else { + $pi = '<' . '?plugin Video file="' . $pi . '" ?>'; + } $this->_element = new Cached_PluginInvocation($pi); return true; } diff --git a/lib/InlineParser.php b/lib/InlineParser.php index 77a9e68bb..1758bb168 100644 --- a/lib/InlineParser.php +++ b/lib/InlineParser.php @@ -1106,7 +1106,12 @@ class Markup_template_plugin extends SimpleMarkup // It's a video if (is_video($imagename)) { - $s = '<' . '?plugin Video file="' . $imagename . '" ?' . '>'; + if ((strpos($imagename, 'http://') === 0) + || (strpos($imagename, 'https://') === 0)) { + $s = '<' . '?plugin Video url="' . $imagename . '" ?' . '>'; + } else { + $s = '<' . '?plugin Video file="' . $imagename . '" ?' . '>'; + } return new Cached_PluginInvocation($s); } diff --git a/lib/plugin/Video.php b/lib/plugin/Video.php index 67e04f08f..c45e1f90f 100644 --- a/lib/plugin/Video.php +++ b/lib/plugin/Video.php @@ -72,7 +72,11 @@ class WikiPlugin_Video global $WikiTheme; $args = $this->getArgs($argstr, $request); - extract($args); + $url = $args['url']; + $file = $args['file']; + $width = $args['width']; + $height = $args['height']; + $autoplay = $args['autoplay']; if (!$url && !$file) { return $this->error(_("Both 'url' or 'file' parameters missing.")); @@ -83,9 +87,18 @@ class WikiPlugin_Video $url = getUploadDataPath() . '/' . $file; } - if (string_ends_with($url, ".ogg")) { - return HTML::video(array('autoplay' => 'true', 'controls' => 'true', 'src' => $url), + if (string_ends_with($url, ".ogg") + || string_ends_with($url, ".mp4") + || string_ends_with($url, ".webm")) { + $video = HTML::video(array('controls' => 'controls', + 'width' => $width, + 'height' => $height, + 'src' => $url), _("Your browser does not understand the HTML 5 video tag.")); + if ($autoplay == 'true') { + $video->setAttr('autoplay', 'autoplay'); + } + return $video; } $html = HTML(); diff --git a/lib/stdlib.php b/lib/stdlib.php index d0f54e66a..8c171f470 100644 --- a/lib/stdlib.php +++ b/lib/stdlib.php @@ -2089,13 +2089,15 @@ function is_image($filename) /** * Returns true if the filename ends with an video suffix. - * Currently only FLV and OGG + * Currently FLV, OGG, MP4 and WebM. */ function is_video($filename) { return string_ends_with(strtolower($filename), ".flv") - or string_ends_with(strtolower($filename), ".ogg"); + or string_ends_with(strtolower($filename), ".ogg") + or string_ends_with(strtolower($filename), ".mp4") + or string_ends_with(strtolower($filename), ".webm"); } /** diff --git a/pgsrc/Help%2FVideoPlugin b/pgsrc/Help%2FVideoPlugin index 251a62bf5..782e5e45a 100644 --- a/pgsrc/Help%2FVideoPlugin +++ b/pgsrc/Help%2FVideoPlugin @@ -1,4 +1,4 @@ -Date: Wed, 18 Mar 2015 15:14:44 +0000 +Date: Wed, 25 Mar 2015 12:24:09 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.5.3) Content-Type: application/x-phpwiki; pagename=Help%2FVideoPlugin; @@ -8,9 +8,9 @@ Content-Transfer-Encoding: binary The **~Video** [[Help:WikiPlugin|plugin]] allows to include video in a wiki page. Video file must be encoded in FLV format ([[WikiPedia:Flash Video|Flash Video]]) or in an HTML 5 format: -* [[WikiPedia:Ogg|Ogg]], -* [[WikiPedia:MP4|MP4]], -* [[WikiPedia:WebM|WebM]]. +* [[WikiPedia:Ogg|Ogg]] (##.ogg## suffix), +* [[WikiPedia:MP4|MP4]] (##.mp4## suffix), +* [[WikiPedia:WebM|WebM]] (##.webm## suffix). The Video plugin can also be called with the ~{~{video.flv~}~} syntax. @@ -41,11 +41,11 @@ Use only one of ##url## or ##file## arguments at a time. | 320 |- | **autoplay** -| Auto play the video when page is displayed. +| Auto play the video when page is displayed (boolean). | false |} -== Example == +== Examples == A video: {{{ @@ -62,6 +62,13 @@ This is equivalent to: {{another_video.flv}} }}} +=== Big Buck Bunny === + +{{{ +{{http://video.webmfiles.org/big-buck-bunny_trailer.webm}} +}}} +{{http://video.webmfiles.org/big-buck-bunny_trailer.webm}} + == Authors == * Roger Guignard, Alcatel-Lucent -- 2.45.0