From MediaWiki.org
<?php
/*
* 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 Christopher Ottley <cottley at gmail dot com>
* @version 1.00
*
* Changelog
* =========
*
* 1.00 - Initial release
*
*/
// Extension credits that show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
'name' => 'FLVPlayer',
'author' => 'Christopher Ottley',
'url' => 'http://www.mediawiki.org/wiki/Extension:FLVPlayer',
'description' => 'Allows the display of flv movies within a wiki using the FlowPlayer FLV movie player.'
);
$wgExtensionFunctions[] = "wfFlvPlayerExtension";
/*
* The FlvPlayer class generates code that embeds a flash movie player
* with reference to the uploaded movie.
*
* The flash based flv player used is flowplayer (http://flowplayer.sourceforge.net/)
*
*/
class FlvPlayer {
/* Constructor */
function FlvPlayer( $input, $argv ) {
global $wgScriptPath;
$this->file = $input;
$this->width = $argv["width"];
$this->height = $argv["height"];
if ($this->width == "") { $this->width = "100"; }
if ($this->height == "") { $this->height = "100"; }
if ($argv["autoplay"] != "") {
$this->flashvars .= "&autoPlay=" . $argv["autoplay"];
}
if ($argv["autobuffering"] != "") {
$this->flashvars .= "&autoBuffering=" . $argv["autobuffering"];
}
if ($argv["bufferlength"] != "") {
$this->flashvars .= "&bufferLength=" . $argv["bufferlength"];
}
if ($argv["loop"] != "") {
$this->flashvars .= "&loop=" . $argv["loop"];
} else {
$this->flashvars .= "&loop=false";
}
if ($argv["progressbarcolor1"] != "") {
$this->flashvars .= "&progressBarColor1=" . $argv["progressbarcolor1"];
}
if ($argv["progressbarcolor2"] != "") {
$this->flashvars .= "&progressBarColor2=" . $argv["progressbarcolor2"];
}
if ($argv["videoheight"] != "") {
$this->flashvars .= "&videoHeight=" . $argv["videoheight"];
}
if ($argv["hidecontrols"] != "") {
$this->flashvars .= "&hideControls=" . $argv["hidecontrols"];
}
if ($argv["hideborder"] != "") {
$this->flashvars .= "&hideBorder=" . $argv["hideborder"];
}
$this->flowplayerpath = $wgScriptPath . "/extensions/flvplayer/FlowPlayer.swf";
}
/* Generate final code */
function render() {
$this->url = $this->getViewPath($this->file);
$this->code = '<object type="application/x-shockwave-flash" data="' . $this->flowplayerpath . '" width="' . $this->width . '" height="' . $this->height . '" id="FlowPlayer"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' . $this->flowplayerpath . '" /><param name="quality" value="high" /><param name="scale" value="noScale" /><param name="wmode" value="transparent" /><param name="flashvars" value="videoFile=' . $this->url . '&baseURL=http://' . $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $this->flashvars . '" /></object>';
return $this->code;
}
function getViewPath($file) {
$title = Title::makeTitleSafe("Image",$file);
$img = new Image($title);
$path = $img->getViewURL(false);
return $path;
}
}
function wfFlvPlayerExtension() {
global $wgParser;
$wgParser->setHook( "flvplayer", "renderFlvPlayer" );
}
function renderFlvPlayer( $input, $argv ) {
// Constructor
$flvPlayerFile = new FlvPlayer( $input, $argv );
$result = $flvPlayerFile->render();
return $result; // send the final code to the wiki
}