Extension talk:FlowPlayerExtension

From MediaWiki.org
Jump to: navigation, search

Contents

[edit] Intro

I made a few changes to the script so that it works with flowPlayer 2.1.2 (or maybe older versions aswell)

I hope this is of use for someone else too.

[edit] Changes

  • removed jquery.flashembed.js in scripttag. Only uses jquery.js now, which is the script that comes with flowplayer by default, only renamed to jquery.js
  • added minimumversion of 9.1 (I use H.264 on my site so...). (will maybe make this a parameter later)
  • shows expressinstaller of new flashversion if minumumversion is not found on the users system. (download expressinstall.swf from the flowplayer site here).
  • changed the call to flashembed() javascript function. The first parameter is now the div element. (changed it since the original way didn't work for me)

[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>
 * @author Hugo van der Vlies <whacko at whacko dot nl>
 * @version 0.30
 * 
 * Changelog
 * =========
 *
 * 0.10 - Initial build with FlowPlayer 1.x
 * 0.20 - Release using FlowPlayer 2.0.1
 * 0.30 - Changes for FlowPlayer 2.1.2 by Hugo van der Vlies (whacko at whacko dot nl)
 */
 
// 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";
$installerpath = $wgScriptPath . "/extensions/flowplayer/expressinstall.swf"; 
 
        $returnString = "<script type='text/javascript' src='/extensions/flowplayer/jquery.js'></script>\n";
        $returnString .= "<div id='playerContainer'></div>\n";
        $returnString .= "<script type=\"text/javascript\">\n";
        $returnString .= "flashembed('playerContainer', {src:'". $flowplayerpath ."',width:".$args["width"].",height:".$args["height"].",version:[9,1],expressInstall:'". $installerpath ."'},\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] Paths and wgScriptPath

Depending on how your webserver directories are configured, you may need the following at the top of the renderFlowPlayer() script. It won't hurt in any event.

global $wgScriptPath;

Also, to be consistent with the script, the directory name in LocalSettings.php should be

require_once("$IP/extensions/flowplayer/FlowPlayerExtension.php");

[edit] Problems setting up FlowPlayerExtension

Hello I am having difficulties setting up this player to play external flv files. I am trying to embed the video here http://asianmediawiki.com/Sisterhood and from this url http://fareastcinema.com/wp-content/uploads/2008/09/sisterhood.flv any tips are appreciated. thanks.

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox