Extension:VideoFlash

From MediaWiki.org

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

Release status: unknown

Implementation Tag
Description VideoFlash is an extension that displays videos from Youtube, GoogleVideo, Dailymotion, Sevenload, Revver and similar services
Author(s) Alberto Sarullo
Version 1.1 (2007-03-24)
MediaWiki 1.6.8 or above
Download see below

VideoFlash VideoFlash is an extension that displays videos from Youtube, GoogleVideo, Dailymotion, Sevenload, Revver and similar services based on FLV video format.

This extension is based on Extension:YouTube (Iubito) extension.

Contents

[edit] Source

Copy the following code into extensions/videoflash.php:

<?php
 
/*******************************************************************************
*                                                                              *
* VideoFlash Extension by Alberto Sarullo, based on YouTube (Iubito) extension *
* http://www.mediawiki.org/wiki/Extension:VideoFlash                           *
*                                                                              * 
*                                                                              * 
* Tag :                                                                        *
*   <videoflash>v</videoflash>                                                 *
*                                                                              *
* Ex :                                                                         *
*   from url http://www.youtube.com/watch?v=4lhyH5TsuPg                        *
*   <videoflash>4lhyH5TsuPg</videoflash>                                       *
*                                                                              *
* Ex:                                                                          *
*   from url http://video.google.it/videoplay?docid=1811233136844420765        *
*   <videoflash type="googlevideo">1811233136844420765</videoflash>            *
*                                                                              *
* Ex:                                                                          *
*   from url http://en.sevenload.com/videos/7DQGFhH/Sexy-Tussis                *
*   <videoflash type="sevenload">7DQGFhH</videoflash>                          *
*                                                                              *
* Ex:                                                                          *
*   from url http://one.revver.com/watch/138657                                *
*   <videoflash type="revver">138657</videoflash>                              *
*                                                                              *
********************************************************************************/ 
 
$wgExtensionFunctions[] = 'wfVideoFlash';
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'VideoFlash',
        'description' => 'VideoFlash (YouTube, GoogleVideo, Dailymotion, sevenload...)',
        'author' => 'Alberto Sarullo',
        'url' => 'http://www.mediawiki.org/wiki/Extension:VideoFlash'
);
 
function wfVideoFlash() {
        global $wgParser;
        $wgParser->setHook('videoflash', 'renderVideoFlash');
}
 
 
# The callback function for converting the input text to HTML output
function renderVideoFlash($input, $args) {
        $input = htmlspecialchars($input);
 
        $type = "youtube";
        $params = explode ("|", $input);
        $id = $params[0];
        $width = 425;
        $height = 350;
        $style = '';
 
        $url['youtube']     = 'http://www.youtube.com/v/'.$id;
        $url['googlevideo'] = 'http://video.google.com/googleplayer.swf?docId='.$id;
        $url['dailymotion'] = 'http://www.dailymotion.com/swf/'.$id;
        $url['sevenload']   = 'http://en.sevenload.com/pl/'. $id .'/'. $width .'x'. $height .'/swf';
        $url['revver']      = 'http://flash.revver.com/player/1.0/player.swf?mediaId='.$id;
        // add here other similar services
 
        if(count($args)>0 && $args['type'] && $url[$args['type']]){
           $type =  htmlspecialchars($args['type']);
        }
 
 
        if (count($params) > 1) {
           $width = $params[1];
           if (count($params) > 2) {
              $height = $params[2];
              if (count($params) > 3) {
                 $style = $params[3];
              }
           }
        }
 
        $output= '<object width="'.$width.'" height="'.$height.'" style="' . $style . '">'
                .'<param name="movie" value="'.$url[$type].'"> <param name="allowfullscreen" value="true" />'
                .'<param name="wmode" value="transparent"></param>'
                .'<embed src="'.$url[$type]
                .'" type="application/x-shockwave-flash" wmode="transparent"'
                .' width="'.$width.'" height="'.$height.'" allowfullscreen="true" style="' 
                . $style . '"';
        if($type=='revver')
                        $output.='flashvars="mediaId='.$id.'&affiliateId=0"';
 
        $output.='></embed></object>';
 
 
        return $output;
 }
?>

[edit] Installation

  • Create the file videoflash.php and paste the code shown above.
  • Upload videoflash.php to your $IP/extensions directory.
  • Add the following lines at the end of LocalSettings.php:
require_once("extensions/videoflash.php");

[edit] Usage

[edit] Youtube

Original url: http://www.youtube.com/watch?v=4lhyH5TsuPg

Wiki code:

<videoflash>4lhyH5TsuPg</videoflash>

or (with width and height):

<videoflash>WZpeeRSk-0A|200|100</videoflash>

[edit] GoogleVideo

Original url: http://video.google.it/videoplay?docid=1811233136844420765

Wiki code:

<videoflash type="googlevideo">1811233136844420765</videoflash>

or (with width and height):

<videoflash type="googlevideo">1811233136844420765|200|150</videoflash>

[edit] DailyMotion

Original url: http://www.dailymotion.com/video/xi23l_geris-game

Wiki code:

<videoflash type="dailymotion">7fiHlJPCjcqK73xbb</videoflash>

or (with width and height):

<videoflash type="dailymotion">7fiHlJPCjcqK73xbb|640|480</videoflash>

[edit] Sevenload

Original url: http://en.sevenload.com/videos/Eh4mjir/Bewegungen-der-Natur

Wiki code:

<videoflash type="sevenload">Eh4mjir</videoflash>

or (with width and height):

<videoflash type="sevenload">Eh4mjir|640|480</videoflash>

[edit] Revver

Original url: http://one.revver.com/watch/138657

Wiki code:

<videoflash type="revver">138657</videoflash>

or (with width and height):

<videoflash type="revver">138657|640|480</videoflash>

[edit] History

  • 1.1 - 2007-03-24 - Added Revver support; fixed xss vulnerability (tnx Jimbojw)
  • 1.0 - 2007-01-23 - First release

[edit] Authors

[edit] MediaWiki Version

  • Successfully tested on MediaWiki 1.6.9, MediaWiki 1.8.4, and MediaWiki 1.9.3.

[edit] Full Screen

/*******************************************************************************
*                                                                              *
* Simple "View in fullscreen" addon by xiandos.info.                           *
*                                                                              *
* At the end, before the output is returned, add:                              *
*                                                                              *
********************************************************************************/ 
 
if (strstr($type, "googlevideo")){
        $output .= '<p><a href="javascript:void(window.open('
        ."'http://video.google.com/googleplayer.swf?docid="
        .$id           
        ."','GooglePlayer','location=no,menubar=no,scrollbars=auto,status=no,"
        ."toolbar=no,fullscreen=yes,dependent=no,left=1,top=1'))"
        .'">View the video in fullscreen</a></p>';
}
 
        return $output;

[edit] Other implementations

  • Video Widgets category on MediaWiki widgets site (has all the widgets this extension supports and more)

[edit] Wikis using videoflash

If you use this extension, please add your website here.

Personal tools