This took me a whole afternoon and involved a lot of hope as I browsed the Internet and no one seemed to have done this before. Fortunately, MediaWiki extensions are easier to write than Joomla CMS ones :c)
This article shows you how to get your MediaWiki system to display your Camtasia Studio SWF files in it's articles.
Why Camtasia when there are other free options?
We tried lots of FLV players that were usually branded or not free. These were awkward to configure a full screen button on the controls and do basic customization. Our screen recorder was also not displaying the captions of the video unless it was an AVI file that we converted to FLV. The quality was horrible. Then we moved to Camtasia Studio where their videos were displaying in good quality but as SWF files. This extension includes the default settings for "ExpressShow" in Camtasia Studio.
My Setup
- MediaWiki v1.14.0
- PHP v5.1.6
- MySQL v5.0.45
- Camtasia Studio v5.0
For Demonstration Purposes
- We want to add a video called "EXAMPLE.SWF" to an article
Let's begin
Create your video in Camtasia Studio and produce the SWF files
- Finish doing your video
- Go to File > Produce Video As... > Custom production settings > Next
- Select 'Flash (SWF/FLV) - Adobe Flash Output' > Next
- ExpressShow (complete optional settings) > Next
- Video Info (complete optional settings) > Make sure "Embed Video into HTML" is checked > Next
- Specify production name and click on 'FINISH'
- This will produce a HTML, SWF, XML and JS file in the output directory. We only want the SWF and JS file.
Add our extension to your Mediawiki extensions
- Create a folder called "bukb_camtasia_player" in your /extensions folder
- Copy the swfobject.js file produced by your Camtasia movie
- Create a new PHP file in your /extensions/bukb_camtasia_player folder called "BUKB_player.php" with the following code:
copyraw
* @version 1.00 * * Changelog * ========= * * 1.00 - Initial release * */ // Extension credits that show up on Special:Version $wgExtensionCredits['parserhook'][] = array( 'name' => 'BUKB Player', 'author' => 'Joel Lipman (based on original flvplayer by Christopher Ottley)', 'url' => 'http://www.joellipman.com/', 'description' => 'Displays videos we have created using Camtasia Studio.' ); $wgExtensionFunctions[] = "wfFlvPlayerExtension"; /* * The FlvPlayer class generates code that embeds a flash movie player * with reference to the uploaded movie. */ class FlvPlayer { /* Generate final code */ function render() { $this->url = $this->getViewPath($this->file); $this->code = ' <div id="media"><div id="noUpdate"><p>The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by <a href="http://www.macromedia.com/go/getflashplayer">downloading here</a>.</p></div></div> // url . '", "csSWF", "640", "550", "9.0.28", "#000000"); so.addParam( "quality", "best" ); so.addParam( "allowFullScreen", "true" ); so.addParam( "scale", "showall" ); so.addParam( "allowScriptAccess", "always" ); so.addVariable( "autostart", "false" ); so.write("media"); // ]]> <!-- Users looking for simple object / embed tags can copy and paste the needed tags below. <div id="media"> <param name="src" value="value" .="." $this-="$this-" />url . '"/> <param name="bgcolor" value="#000000" /> <param name="quality" value="best" /> <param name="allowScriptAccess" value="always" /> <param name="allowFullScreen" value="true" /> <param name="scale" value="showall" /> <param name="flashVars" value="autostart=false" /> url . '" width="640" height="550" bgcolor="#1a1a1a" quality="best" allowScriptAccess="always" allowFullScreen="true" scale="showall" flashVars="autostart=false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> </div> --> '; 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( "bukbplayer", "renderFlvPlayer" ); } function renderFlvPlayer( $input, $argv ) { $result = $flvPlayerFile->render(); return $result; // send the final code to the wiki }
- * @version 1.00
- *
- * Changelog
- * =========
- *
- * 1.00 - Initial release
- *
- */
- // Extension credits that show up on Special:Version
- $wgExtensionCredits['parserhook'][] = array(
- 'name' => 'BUKB Player',
- 'author' => 'Joel Lipman (based on original flvplayer by Christopher Ottley)',
- 'url' => 'http://www.joellipman.com/',
- 'description' => 'Displays videos we have created using Camtasia Studio.'
- );
- $wgExtensionFunctions[] = "wfFlvPlayerExtension";
- /*
- * The FlvPlayer class generates code that embeds a flash movie player
- * with reference to the uploaded movie.
- */
- class FlvPlayer {
- /* Generate final code */
- function render() {
- $this->url = $this->getViewPath($this->file);
- $this->code = '
- <div id="media"><div id="noUpdate"><p>The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by <a href="http://www.macromedia.com/go/getflashplayer">downloading here</a>.</p></div></div>
- // url . '", "csSWF", "640", "550", "9.0.28", "#000000");
- so.addParam( "quality", "best" );
- so.addParam( "allowFullScreen", "true" );
- so.addParam( "scale", "showall" );
- so.addParam( "allowScriptAccess", "always" );
- so.addVariable( "autostart", "false" );
- so.write("media");
- // ]]>
- <!-- Users looking for simple object / embed tags can copy and paste the needed tags below.
- <div id="media">
- <param name="src" value="value" .="." $this-="$this-" />url . '"/>
- <param name="bgcolor" value="#000000" />
- <param name="quality" value="best" />
- <param name="allowScriptAccess" value="always" />
- <param name="allowFullScreen" value="true" />
- <param name="scale" value="showall" />
- <param name="flashVars" value="autostart=false" />
- url . '" width="640" height="550" bgcolor="#1a1a1a" quality="best" allowScriptAccess="always" allowFullScreen="true" scale="showall" flashVars="autostart=false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
- </div>
- -->
- ';
- 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( "bukbplayer", "renderFlvPlayer" );
- }
- function renderFlvPlayer( $input, $argv ) {
- $result = $flvPlayerFile->render();
- return $result; // send the final code to the wiki
- }
Amend your skin files
Amend your skins to include the reference to this script in between the head tags of every page, so
<head> <!-- START BUKB CAMTASIA PLAYER //--> <script type="text/javascript" src="/extensions/bukb_camtasia_player/swfobject.js"></script> </head>
- <head>
- <!-- START BUKB CAMTASIA PLAYER //-->
- <script type="text/javascript" src="/extensions/bukb_camtasia_player/swfobject.js"></script>
- </head>
Amend your LocalSettings.php file
require_once("$IP/extensions/bukb_camtasia_player/BUKB_player.php");
- require_once("$IP/extensions/bukb_camtasia_player/BUKB_player.php");
View your file in MediaWiki
- Upload the SWF file to your mediawiki system. (if you have problems with this see my article on overriding the MediaWiki system to allow SWF file uploads)
- Refer to it in an article using the syntax:
Image:Example.swf (Replace the swf file name with the name of your SWF file).
Download these files
You can download these files by going to our downloads section and downloading the BUKB_Camtasia_Player.zip file.