Extension:EmbeddedVideo
From MediaWiki.org
|
EmbeddedVideo Release status: beta |
|
|---|---|
| Implementation | Tag, Media |
| Description | embeds uploaded videos into pages |
| Author(s) | Russel Philip (Russel Talk) |
| MediaWiki | tested on 1.11 |
| Download | Extension:EmbeddedVideo#Code |
Contents |
[edit] What can this extension do?
Currently this extension uses vPIP to play video files, previously uploaded into the wiki, either directly inline with the page or in a "thickbox" overlay. It should be noted that vPIP uses j�Query, and is not the most stable thing. vPIP will also automatically play links to supported media files in its thickbox. I have consistently experienced Firefox redraw issues after playing files using vPIP 1.12. I would ideally like to allow admins to specify different media players.
[edit] Usage
<video caption="a sample mp4">sample.mp4</video>
[edit] Parameters
- width
- width in pixels, defaults to 320
- height
- width in pixels, defaults to 240
- title
- video title, defaut
- caption
- defaults to the title if not specified. To exclude, set to none
- image
- preview show inline. Defaults to included clip image
- type
- mimetype, defaults to auto
- download
- defaults to false
- autostart
- defaults to true
- controller
- defaults to true
- thickbox
- defaults to false
[edit] vPIP
See http://vpip.org/ for a list of supported media formats
[edit] Download instructions
Please cut and paste the code found below and place it in $IP/extensions/EmbeddedVideo/EmbeddedVideo.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
[edit] Installation
- Download the latest version of vPIP and move all of the files into the EmbeddedVideo folder
- Add the following to LocalSettings.php:
require_once("$IP/extensions/EmbeddedVideo/EmbeddedVideo.php");
[edit] Configuration parameters
?
[edit] User rights
?
[edit] Code
<?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 Russel Philip * @version 0.1 * * Changelog * ========= * * 0.0 - Initial release * 0.1 - */ $wgExtensionFunctions[] = 'wfEmbeddedVideo'; $wgExtensionCredits['parserhook'][] = array( 'name' => 'Embedded Video', 'description' => 'uses vPIP to embed videos into pages', 'author' => 'Russel Philip', 'url' => 'http://www.mediawiki.org/wiki/Extension:EmbeddedVideo', 'version' => '0.1' ); $wgvPIPResources = false; function wfEmbeddedVideo() { global $wgParser; $wgParser->setHook('video', 'embedVideo'); } function embedVideo( $input, $argv ) { $video = new vPIPPlayer( $input, $argv ); $result = $video->render(); return $result; } class vPIPPlayer{ /* Constructor */ function vPIPPlayer($input, $args) { global $wgvPIPResources; // Make sure that vPIP has been loaded if (!$wgvPIPResources) $wgvPIPResources = $this->loadvPIPResources(); // Default parameter values $this->file = $input; $this->parameters['width'] = '320'; $this->parameters['height'] = '260'; $this->parameters['title'] = false; $this->parameters['caption'] = false; $this->parameters['image'] = false; $this->parameters['type'] = "auto"; $this->parameters['download'] = false; $this->parameters['autostart'] = "true"; $this->parameters['controller'] = "true"; $this->parameters['thickbox'] = "false"; // Load user specified parameter values foreach($args as $parameter => $value){ $this->parameters[$parameter] = $value; } // Verify the media file if(strstr($this->file,'http://') == $this->file){ $this->url = $this->file; }else{ $this->url = $this->getViewPath($this->file); } // Verify the image file if($this->parameters['image'] and !(strstr($this->parameters['image'],'http://') == $this->file )) $this->parameters['image'] = $this->getViewPath($this->parameters['image']); // Set the title if (!$this->parameters['title']) $this->parameters['title'] = $this->file; // Set the caption if (!$this->parameters['caption']) $this->parameters['caption'] = $this->parameters['title']; // Determin the mimetype if ($this->parameters['type'] == "auto") { $extension = substr($this->file, -3, 3); switch (strtolower($extension)) { case "mov": $this->parameters['type'] = 'type="video/quicktime"'; break; case "mp4": $this->parameters['type'] = 'type="video/mp4"'; break; case "m4v": $this->parameters['type'] = 'type="video/x-m4v"'; break; case "mp3": $this->parameters['type'] = 'type="audio/x-mp3"'; break; case "smi": $this->parameters['type'] = 'type="application/smil"'; break; case "3gp": $this->parameters['type'] = 'type="video/3gpp"'; break; case "avi": $this->parameters['type'] = 'type="video/x-msvideo"'; break; case "wmv": $this->parameters['type'] = 'type="video/x-ms-wmv"'; break; case "asf": $this->parameters['type'] = 'type="video/x-ms-asf"'; break; case "wma": $this->parameters['type'] = 'type="audio/x-ms-wma"'; break; case "swf": $this->parameters['type'] = 'type="application/x-shockwave-flash"'; break; case "flv": $this->parameters['type'] = 'type="application/x-shockwave-flashf"'; break; default: $this->parameters['type'] = ""; } } } /* Generate final code */ function render(){ $this->code .= '<div class="hvlog" style="position: relative;">'; $this->code .='<a href="'.$this->url.'" rel="enclosure" class="hVlogTarget" title="'.$this->parameters['title'].'" type="'.$this->parameters['type'].' onclick="vPIPPlay(this, \'width='.$this->parameters['width'].', height='.$this->parameters['height'].', autostart='.$this->parameters['autostart'].', controller='.$this->parameters['controller'].', name=MyMovie, revert=true\', \'\', \'active='.$this->parameters['thickbox'].', caption='.$this->parameters['caption'].'\'); return false;">'; if ($this->parameters['image']) $this->code .='<img width='.$this->parameters['width'].', height='.$this->parameters['height'].' src="'.$this->parameters['image'].'" />'; else $this->code .='<img width=128, height=128 src="extensions/EmbeddedVideo/video.png" />'; if ($this->parameters['caption'] and ($this->parameters['caption']!= 'none')) $this->code .='<p>'.$this->parameters['caption'].'</p>'; $this->code .='<div style="position:absolute; left: 5px; top: 5px; font-weight: bold;"><img src="extensions/EmbeddedVideo/PlayButton.png" \></div>'; $this->code .='</a>'; if ($this->parameters['download']) $this->code .= '<div style="position:absolute; left: 5px; top: 60px;"><a href="'.$this->url.'"><img src="extensions/EmbeddedVideo/SaveButton.png" \></a></div>'; $this->code .= '</div>'; return $this->code; } /* get file url */ function getViewPath($file) { $title = Title::makeTitleSafe("Image",$file); $img = new Image($title); $path = $img->getViewURL(false); return $path; } function loadvPIPResources(){ global $wgOut; $vpip .=<<<JAVASCRIPT <style type="text/css"> @import "extensions/EmbeddedVideo/vPIPBox.css"; </style> <script> //<![CDATA[ function addScript(script) { var js = document.createElement("script"); js.setAttribute('src', script); js.setAttribute('type', 'text/javascript'); document.body.appendChild(js); } addScript('extensions/EmbeddedVideo/vpip.js'); addScript('extensions/EmbeddedVideo/jquery.js'); addScript('extensions/EmbeddedVideo/vpipit.js'); //]]> </script> JAVASCRIPT; return $wgOut->addHTML($vpip); } }
[edit] See also
?

