DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:videogg

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

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

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

Q1

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.

Answer 1.1

Yes, this is possible. Just add 4 lines of PHP code in function render. function render sould begin like this :

function render($mode, &$renderer, $data) {
    if($mode == 'xhtml'){
      list($state, $params) = $data;
      list($video_url, $video_size) = $params;
      // If no '/' in video url, then it's not an url, it's a media ID, so get the url.
      if( !substr_count( $video_url, '/' ) ) {
        $video_url=ml($video_url);
      }
      .... rest of the function is unchanged.

Then you can still use the original syntax. And you can also use videos from your wiki using syntax like this :

{{videogg>somevideo.ogv}}
{{videogg>:some:namespace:avideo.ogv}}

schplurtzschplurtz

2012/05/25 18:09

Q2

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

A2

Hi Michel, I just contacted the author1) whether this plugin is orphaned or not, if yes I would like to adopt it. Regarding your question, help is on the way :-)
I rewrote the plugin a bit and now you can use the audio-tag as well as the video-tag. Extra bling-bling like automatic conversion of multi-mp3 to one ogg-file is also on board.
Will commit the new syntax.php within this month.

Q3

Hi, excuse me for the bad English… How can I use this plugin to the simple ogg vorbis audiofiles, without video-track? For ekzample, for an ogg vorbis music?

— violazoli 2013/09/13 23:21

Thanks !

I'm just back from a long trip. I'll try this new version of the plugin ASAP. Thank you for your concern.

Michel

1)
Ludovic just mailed the “ok” for me taking over his plugin. Thanks Ludovic!
plugin/videogg.txt · Last modified: 2013-09-14 05:19 by 71.58.88.72