Extension:FlowPlayerExtension

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
FlowPlayerExtension

Release status: beta

Implementation Tag
Description This allows you to embed FLV files through the use of FlowPlayer 2.x
Author(s) Avidan Ross (avidan Talk)
Version 0.2
Download no link

Contents

[edit] What can this extension do?

This extension will allow you to embed Flash movie files in your Media Wiki Site. You can refer to external Flash Movie, or upload FLV files directly to your MediaWiki site.

[edit] Usage

Create a new directory in your mediawiki extensions folder: extensions/flowplayer/.

Download and install the 3 following files from www.flowplayer.org and place them in the flowplayer extension folder.

  1. You first need to download jQuery. You can do that here: http://jquery.com/ Rename the file to jquery.js, and place it in the flowplayer folder.
  2. Then, download the flashembed.js script found here: FlowPlayer.org Rename the flashembed.js file to jquery.flashembed.js
  3. Now, you need the actual flash player, which will play the FLV movie files you upload. Flash Movie files are available here: SourceForge. Download the zip file and unzip it in the flowplayer extension directory. In the newly unzipped flowplayer directory, copy any of the four FlowPlayer swf files to the main extensions/flowplayer/ directory. Each of them is slightly different, but in order to use them, you'll have to copy and rename the swf file to FlowPlayer.swf.

[edit] Download instructions

Please cut and paste the code found below and place it in $IP/extensions/FlowPlayerExtension/FlowPlayerExtension.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

[edit] Installation

To install this extension, add the following to LocalSettings.php:

array_push($wgFileExtensions,'flv'); //allows you to upload FLV files
require_once("$IP/extensions/FlowPlayerExtension/FlowPlayerExtension.php");

[edit] Configuration parameters

Upload an FLV file called Demo, and embed it like this: <flowplayer height="480" width="640" autoplay="true">Image:Demo.flv</flowplayer>

Here are some common configuration items:

  • configFileName An external javascript configuration file.
  • videoFile The video file to be loaded by the player. You can specify an absolute URL here or a relative one (relative to the embedding HTML file). See the baseURL below. Alternatively you can use a playList.
  • baseURL Where to load the video files from. This is appended in front of the value of videoFile value. If not specified, the file is loaded from the same directory as the HTML file.
  • autoPlay [true || false] Whether the player starts playback immediately when it's loaded into the browser. default: true
  • autoBuffering Whether to start loading the video stream into buffer memory immediately. Only meaningful if autoPlay is set to false default: true.
  • usePlayOverlay [true || false] Show the play button image at the start of the playlist? default: true
  • splashImageFile Useful if 'autoPlay' is set to false and you want to show a welcome image before the video is played. Must be JPG format. note: value is relative to the HTML page.
  • initialScale

Initial video scaling. This can be then changed by the user through the menu. Available options are:

   fit: Fit to window by preserving the aspect ratios encoded in the FLV metadata. This is the default setting.
   half: Half size (preserves aspect ratios)
   orig: Use the dimensions encoded in FLV. If the video is too big for the available space the video is scaled as if using the 'fit' option.
   scale: Scale the video to fill all available space for the video. Ignores the dimensions in metadata.


  • videoHeight The height to be allocated for the video display. By default Flowplayer uses the maximium height available.
  • useNativeFullScreen [true || false] Should the Flash 9 native full screen mode be used? (default: true).
  • fullScreenScriptURL The URL pointing to a sctipt that opens the player full screen. If this is not configured explicitly, the default script, http://flowplayer.org/video/x_xx/fullscreen.js, is used. NOTE: Only used when useNativeFullScreen is not set to false.
  • bufferLength The size of the buffer in seconds when streaming FLV. Playback starts only after the buffer is full. The value should always be less than the duration of the video. (default: 10)
  • startingBufferLength The video buffer length (seconds) to be used to kick off the playback. This is used in the beginning of the playback and every time after the player has ran out of buffer memory.
  • useSmoothing [true || false] Whether to use antialiasing when the video is scaled. default: true
  • videoLink A link to the video file that is shown when "Embed" is selected in the menu. Option, defaults to the url specified in videoFile or playList.
  • emailPostUrl The URL used when posting the email data to the server.
  • emailVideoLink The value of videoLink variable posted as part of the email data.
  • emailDefaultMessage The default message text used as part of the email data. All occurrences of [video_link] tag in the message are replaced with the value of emailVideoLink.

[edit] User rights

[edit] Code

<?
/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USAw
 *  
 * @author Avidan Ross <avidan at cimgroup dot com>
 * @version 0.20
 * 
 * Changelog
 * =========
 *
 * 0.10 - Initial build with FlowPlayer 1.x
 * 0.20 - Release using FlowPlayer 2.0.1
 */
 
// Extension credits that show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'FlowPlayerExtension',
        'author' => 'Avidan Ross',
        'url' => 'http://www.mediawiki.org/wiki/Extension:FlowPlayerExtension',
        'description' => 'Allows the display of flv movies within a wiki using the FlowPlayer movie player.'
);
 
$wgExtensionFunctions[] = "FlowPlayerExtension";
 
 
function FlowPlayerExtension() {
  global $wgParser;
  $wgParser->disableCache();
  $wgParser->setHook( "flowplayer", "renderFlowPlayer" );
}
 
function renderFlowPlayer( $input, $args ) {
 
//if width and height are not set, give defaults 
    if(is_null($args["width"])) $args["width"] = 240;
    if(is_null($args["height"])) $args["height"] = 320;
 
if($args["advanced"] != "")
{
$flowPlayerVariables =array(
"videoFile","baseURL","autoPlay","autoBuffering","usePlayOverlay",
"splashImageFile","initialScale","videoHeight","useNativeFullScreen",
"fullScreenScriptURL","bufferLength","startingBufferLength","useSmoothing",
"videoLink","emailPostUrl","emailVideoLink","emailDefaultMessage","url","name","live",
"start","end","protected","type","linkUrl","linkWindow","overlay","overlayId","duration","controlEnabled",
"allowResize","showOnLoadBegin","maxPlayCount");
}
else
{
$flowPlayerVariables =array(
"videoFile","baseURL","autoPlay","autoBuffering","usePlayOverlay",
"splashImageFile","initialScale","videoHeight","useNativeFullScreen",
"fullScreenScriptURL","bufferLength","startingBufferLength","useSmoothing",
"videoLink","emailPostUrl","emailVideoLink","emailDefaultMessage");
}
 
$flashvars = "{config: { ";
 
//if no "videofile" is set, use the local wiki file
if (is_null($args["videofile"])) $flashvars .= " videoFile:" . "'" . getViewPath($input) ."'". ",";
 
foreach ($flowPlayerVariables as $configVariableName)
{
//for some reason, mediawiki passes all arguments in lower case
    if (isset($args[strtolower($configVariableName)])) {
      if($args[strtolower($configVariableName)] == "true" | $args[strtolower($configVariableName)] == "false")
        { $flashvars .= " $configVariableName:" . $args[strtolower($configVariableName)]. ","; }
      else
        { $flashvars .= " $configVariableName:" . "'" . $args[strtolower($configVariableName)] . "'" . ","; }
 
    }
}
 
//remove the last ,
$flashvars = rtrim($flashvars,",");
$flashvars .= "}})";
$flowplayerpath = $wgScriptPath . "/extensions/flowplayer/FlowPlayer.swf";
 
        $returnString = "<script type='text/javascript' src='/extensions/flowplayer/jquery.js'></script><script type='text/javascript' src='/extensions/flowplayer/jquery.flashembed.js'></script>\n";
        $returnString .= "<div id='playerContainer'></div>\n";
        $returnString .= "<script type=\"text/javascript\">\n";
        $returnString .= "$(\"#playerContainer\").flashembed({src:'". $flowplayerpath ."',width:".$args["width"].",height:".$args["height"]."},\n";
        $returnString .= $flashvars;
        $returnString .= "</script>\n";
 
        return $returnString;
}
 
 
  function getViewPath($file) {
    $title = Title::makeTitleSafe("Image",$file);
 
    $img = new Image($title);
 
    $path = $img->getViewURL(false);
 
    return $path;
  }

[edit] See also

All basic configuration items can be used: FlowPlayerConfiguration

Personal tools