videogg plugin

Compatible with DokuWiki

dokuwiki-2009-12-25

plugin Show Ogg Theora videos in your pages

Last updated on
2010-03-04
Provides
Syntax

Tagged with html5, ogg, theora, video, vorbis

Download and Installation

Paste the source code in a file named syntax.php and put it the lib/plugins/videogg directory of your DokuWiki installation.

Source code:

lib/plugins/videogg/syntax.php
<?php
/**
 * Plugin Videogg: Show Theora video from url.
 *
 * @license    GPL v3 (http://www.gnu.org/licenses/gpl.html)
 * @author     Ludovic Kiefer
 *
 * Based on the Dailymotion plugin written by Christophe Benz,
 * which is based on the Youtube plugin written by Ikuo Obataya.
 */
 
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
 
class syntax_plugin_videogg extends DokuWiki_Syntax_Plugin {
  function getInfo(){
    return array(
      'author' => 'Ludovic Kiefer',
      'email'  => 'ludovic _AT_ skolelinux _DOT_ com',
      'date'   => '2010-03-04',
      'name'   => 'OGG Video Plugin',
      'desc'   => 'Show Ogg Theora videos, using the html5 video tag.',
      'url'    => 'http://www.dokuwiki.org/plugin:videogg',
    );
  }
 
  function getType() { return 'substition'; }
  function getSort() { return 159; }
 
  function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{videogg>[^}]*\}\}', $mode, 'plugin_videogg'); }
 
  /**
   * Handle the match
   */
  function handle($match, $state, $pos, &$handler){
    $params = substr($match, strlen('{{videogg>'), - strlen('}}') ); // Strip markup
    return array($state, explode('|', $params));
  }	
 
  /**
   * Create output
   */
  function render($mode, &$renderer, $data) {
    if($mode == 'xhtml'){
      list($state, $params) = $data;
      list($video_url, $video_size) = $params;
 
      if(substr($video_url,-3) != 'ogg' && substr($video_url,-3) != 'ogv') {
        $renderer->doc .= 'Erreur: La vidéo doit avoir l\'extention ogv ou ogg.<br/>'.$video_url;
        return false;
      }
 
      if(is_null($video_size) or ! substr_count  ( $video_size  , 'x')) {
        $width  = 200;
        $height = 166;
      }
      else{
      	$obj_dimensions = explode('x' , $video_size);
      	$width          = $obj_dimensions[0];
     	   $height         = $obj_dimensions[1];
      }
 
 
 
      //$obj  = '<div>';
      $obj .= '<video src="'. $video_url .'" width="'. $width .'" height="'. $height .'" controls></video><br/>'; 
      $obj .= '<a href="'. $video_url .'"><small>Télécharger la vidéo</small></a>';      
      //$obj .= '</div>';
 
      $renderer->doc .= $obj;
 
      return true;
    }
    return false;
  }
}
?>

Syntax and Usage

This plugin use the new html5 <video> tag, and require compatible browser (like Firefox 3.5+ or Gecko/Webkit based browser).

Syntax:

{{videogg>URL|SIZE}}

URL should be the complete address of the video file, with ogg or ogv file extension.
SIZE is the video player size in pixel, width and height must be separate by a “x” character. If not defined, size will be 200×166.

Example:

{{videogg>http://people.xiph.org/~maikmerten/demos/BigBuckBunny.ogv|320x240}}

Miscellaneous

Plugin written for the skolelinux.fr website. If you want to share any idea to improve this script, you can email me (code is better than idea ;) ).

Questions

Hi there, I like this Plugin but is it possible to use the dokuwiki fetch.php? So you could use videos of your own wiki instead external links. Thanks in advance, Mathias.

Hello ! Nice plugin !! I started to use it not so long ago, and I'm convinced. I tried to use is for OGG sounds. It works, but I would really apreciate to be able to read OGG Vorbis files without any comment underneath, and with a stable height. Is it possible, and How ? Thank you for the good job already done. Michel

plugin/videogg.txt · Last modified: 2011/08/29 11:36 by 2a01:e34:ee7e:ed80:21d:4fff:fe4b:c715
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate