Extension:Player

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.svg
Player

Release status:Extension status unmaintained

ImplementationTemplate:Extension#type Special page, Tag, Media
DescriptionTemplate:Extension#description Provides embedded multimedia playback using common browser plugins or embedded players.
Author(s)Template:Extension#username Duesentrieb
MediaWikiTemplate:Extension#mediawiki 1.10 (perhaps 1.9 too)
LicenseTemplate:Extension#license No license specified
Download Template:WikimediaDownload/svn
README
log
ParametersTemplate:Extension#parameters

$wgPlayerTemplates, $wgPlayerMimeOverride, $wgPlayerVideoResolutionDetector

Hooks usedTemplate:Extension#hook
OutputPageParserOutputManual:Hooks/OutputPageParserOutput

Translate the Player extension if it is available at translatewiki.net

Check usage and version matrix.

The Player extension provides a special page, Special:Player, that allows playback of video and other multimedia content uploaded to the wiki - you can make a playback link like this: [[Special:Player/Test.mpg]]. It also provides a custom tag, <player>, that allows multimedia content to be embedded into wiki pages and played on demand (embedded playback requires Ajax; without Ajax, a link to the player page is provided).

Note that this extension is experimental and basically an ugly kludge while waiting for more flexible media file handling facilities in MediaWiki proper.

How it works[edit]

Per default, the Player extension relies on browser plugins for playback - this means that if you want to play a movie, your browser has to have a plugin for this type of movie installed. But the Player extension can also be configured to use a server-supplied player that is based on Macromedia Flash or Java. For example, the FlowPlayer Flash script (Apache License) can be used to play Flash Video files (FLV), or Flumotion's Cortado Java applet (GPL) can be used to play OGG files - this way, users need to have Flash resp. Java installed (which is wide spread), instead of having to have codecs for FLV and OGG installed (which is rare - the VLC plugin supports both, though).

Whether the media file can actually be seen by the user depends on his/her browser and installed plugins, as well as the operating system and configuration of all this. The table below shows some combinations that have been tried out. Please add you own experience, especially with different operating systems, browsers or plugins.

Format OS Browser Plugin Player Works? Comment Signature
FLV (Flash Video) Linux (Ubuntu 6.10) FireFox 2.0 MPlayer (2:0.99+1.0) - No unknown MIME type Duesentrieb 11:06, 14 March 2007 (UTC)
FLV (Flash Video) Linux (Ubuntu 6.10) FireFox 2.0 Macromedia Flash 7 FlowPlayer Yes Duesentrieb 10:42, 14 March 2007 (UTC)
FLV (Flash Video) Linux (Ubuntu 6.10) Konqueror 3.5.5 KMPlayer (2:0.99+1.0) - No unknown MIME type Duesentrieb 11:06, 14 March 2007 (UTC)
FLV (Flash Video) Linux (Ubuntu 6.10) Konqueror 3.5.5 Macromedia Flash 7 FlowPlayer No Duesentrieb 11:06, 14 March 2007 (UTC)
MPEG Linux (Ubuntu 6.10) FireFox 2.0 MPlayer (2:0.99+1.0) - Yes Duesentrieb 10:42, 14 March 2007 (UTC)
MPEG Linux (Ubuntu 6.10) Konqueror 3.5.5 KMPlayer (2:0.99+1.0) - Yes Duesentrieb 11:06, 14 March 2007 (UTC)
MPEG Windows 2003 Server IE6 & 7 mediaPlayer - Yes User:iforci 19:16, 11 Febrary 2009 (UTC)
OGG (vorbis, theora) Linux (Ubuntu 6.10) FireFox 2.0 MPlayer (2:0.99+1.0) - Yes Duesentrieb 10:42, 14 March 2007 (UTC)
OGG (vorbis, theora) Linux (Ubuntu 6.10) Konqueror 3.5.5 KMPlayer (2:0.99+1.0) - Yes Duesentrieb 11:06, 14 March 2007 (UTC)
OGG (vorbis, theora) Linux (Ubuntu 6.10) FireFox 2.0 Java (Sun JRE 1.5.0) Cortado Yes Duesentrieb 10:42, 14 March 2007 (UTC)
OGG (vorbis, theora) Linux (Ubuntu 6.10) Konqueror 3.5.5 Java (Sun JRE 1.5.0) Cortado No player hangs Duesentrieb 11:06, 14 March 2007 (UTC)
SWF (Flash) Linux (Ubuntu 6.10) FireFox 2.0 Macromedia Flash 7 - Yes Duesentrieb 10:42, 14 March 2007 (UTC)
SWF (Flash) Linux (Ubuntu 6.10) Konqueror 3.5.5 Macromedia Flash 7 - Yes Duesentrieb 11:06, 14 March 2007 (UTC)

Installing[edit]

Copy the Player directory into the extensions folder of your MediaWiki installation. Then add the following line to your LocalSettings.php file (near the end):

require_once( "$IP/extensions/Player/Player.php" );

Installing Flash/Java-based players[edit]

To install third-party players for use by the Player extension, get the files required by the player and put them into the directory you installed the Player extension in. Then create a template that uses the player, and assign it to the desired MIME types using the $wgPlayerTemplates setting (see below). In PlayerDefaultSettings.php there are example templates for FlowPlayer and the Cortodo player.

Configuration[edit]

The Player extension can be configured in several ways. The Default configuration, along with some notes and documenation, are in the PlayerDefaultSettings.php file. Some important settings are described below:

$wgUseAjax
this is a global MediaWiki setting. You have to set it to true to enable embedded playback. If not enabled, or if the browser does not support JavaScript or has it disabled, a link to the player page will be provided instead of an embedded player.
$wgPlayerTemplates
this is an array that contains a template for each MIME-type that should be handeled by the Player plugin (see Templates below).
$wgPlayerMimeOverride
this is a map of mime-type aliases. This allows you to override the mime type that will be passed to the player template. For example, video/ogg is per defautl mapped to application/ogg, since some browser plugins don't recognize video/ogg.
$wgPlayerVideoResolutionDetector
this is used to configure the program used to detect the resolution (size) of videos. It can be set to false or null to disable resolution detection, or to a string to use the same detection command, for everything, or to an array mapping mime types to detection commands (using the entry for "*" as a fallback). Each entry in the array by itself be a string specifying a command, or an array containing three fields: command, outpattern and outreplace, where outpattern is a PCRE regular expression, and outreplace is a replacment string for that pattern. This can be used transform the commands output into the form expected by the Player extension, namely the form 400x300. There are two example settings in PlayerDefaultSettings.php, both commented out. One uses mplayer for everything, the otehr uses ogginfo for ogg files and mplayer for the rest. Note that for now, the detector command is run every time a player or placeholder is rendered.

Templates[edit]

Player templates are HTML-snippets for embedding something into the HTML output that allows a specific media file to be played (usually, a template would generate an <object>, <embed> or <applet> tag). In a template, placeholders for template parameters are used to adopt the template for a specific media file (see below).

The $wgPlayerTemplates maps the MIME type of a given file to a template. If no template is defined for that type, playback is not allowed. If the "forcegeneric" option is used, the entry for the pseudo-type "generic" is always used, regardles of the file's actual type or the template associated with that type.

PlayerDefaultSettings.php defines several templates for your conveniance:

$wgPlayerGenericTemplate
generates a generic <object> tag with fallback to <embed> for old browsers. This is used for almost everything per default.
$wgPlayerSvgPluginTemplate
like $wgPlayerGenericTemplate, but works around a problem with some SVG plugins by providing an extra src parameter. Used per default for image/svg+xml
$wgPlayerFlashPluginTemplate
generates specialized <object> and <embed> tags for the Macromedia Flash/ShockWave plugin. Used per default for application/x-shockwave-flash
$wgPlayerFlowPlayerTemplate
template for embedding the FlowPlayer for playback of FLV files. Not enabled per default; you can enable it by using the line for video/x-flv from PlayerDefaultSettings.php. Requires FlowPlayer from http://flowplayer.sourceforge.net Note that this has been tested successfully only with the "Light" version of FlowPlayer, other versions seemed to have some problem.
$wgPlayerCortadoPlayerTemplate
template for embedding the Cortado player for playback of OGG files. Not enabled per default; you can enable it by using the line for audio/ogg, video/ogg and application/ogg from PlayerDefaultSettings.php. Requires Cortado player from http://www.flumotion.net/cortado/

In PlayerDefaultSettings.php, $wgPlayerGenericTemplate is assigned to most common media types, including mp3, wav, midi, ogg, mpeg, avi, and pdf.

See Manual:Configuring file uploads for information on allowing specific file types for upload. See Manual:Mime type detection for information on MIME type detection.

Template Parameters[edit]

Template parameters have the form {{{xxx}}}. They are used as placeholders for values that apply to a specific media file, and will be replaced by the respective values before output. There are several forms of parameters:

  • {{{foo}}} is a simple parameter - it will expand to the value of the option "foo", or be removed if "foo" is not set.
  • {{{foo|quux}}} is a parameter with default value - it will expand to the value of the option "foo", or to "quux" if "foo" is not set.
  • {{{#env:wgFoo}}} is an environment parameter - it will expand to the value of the global variable "wgFoo".

This can be used to access global variables like $wgPlayerExtensionPath, $wgServer, $wgJsMimeType, $wgScriptPath, etc.

  • {{{#attr:foo}}} is an attribute-parameter - it will expand to foo="baz" (where baz is the value of the "foo" option).
  • <nowiki>{{{#attr:foo|bar}}}</nowiki> is an attribute-parameter with name-alias - it will expand to bar="baz" (where baz is the value of the "foo" option).
  • {{{#param:foo}}} is an param-tag-parameter - it will expand to <param name="foo" value="baz"/> (where baz is the value of the "foo" option).
  • {{{#param:foo|bar}}} is an param-tag-parameter with name-alias - <param name="bar" value="baz"/> (where baz is the value of the "foo" option).
  • {{{#ifset:foo|some text}}} is a conditional block - the value "some text" will be output only if the "foo"-option is set, otherwise the entire block is ignored. There is limmited support for nesting: ifset blocks can contain other template parameters, but not other ifset or ifunset blocks.
  • {{{#ifunset:foo|some text}}} is a inverse conditional block - the value "some text" will be output only if the "foo"-option is NOT set, otherwise the entire block is ignored. There is limmited support for nesting: ifunset blocks can contain other template parameters, but not other ifset or ifunset blocks.

The following template parameters are always available:

  • uniq: a unique string, may be used to mark and refer to HTML elements using the id attribute.
  • url: the (local) URL of the media file.
  • fullurl: the full URL of the media file.
  • type: MIME-type media file (subject to $wgPlayerMimeTypeOverride).
  • width: the effective width, in pixels, the player should occupy.
  • height: the effective height, in pixels, the player should occupy.
  • pageurl: the URL of the file's description page in the wiki.
  • filename: plain name of the media file.
  • plainalt: an alternative text suitable for use in HTML attrbutes (such as alt or title). Generally the file name.
  • htmlalt: HTML-text that may be shown instead of the player. Generally a link to the file's description page.

The following global variables (accessible by the {{{#env:xxx}}} syntax) may be particularly interresting:

  • $wgPlayerExtensionPath: The URL path to the extension's installation directory. This may be used to reference secondary files in that directory, such as CSS or JS files, player scripts (SWF or JAR files), etc.
  • $wgScriptPath: URL path to MediaWiki's installation root. Usefull for building URLs.
  • $wgServer: Host- and protocol part of MediaWiki's server. Usefull for building URLs.

Additional parameters may be passed from attributes the user supplies in a <player> tag, or on the Special:Player page. User-supplied parameteres are always HTML-escaped.

Usage[edit]

The <player> tag can be used to embed videos and other multimedia content into wiki pages.

   <player>Testing.mpg</player>                this embeds the Testing.mpg file
   <player>Testing.mpg | some text</player>    this embeds the Testing.mpg file with a caption
   <player align="right" width="200">Testing.mpg</player>    floating right-aligned, 200 pixels wide.

Tag Attributes[edit]

The following attributes can be usedin <player> tags:

id
sets the global ID for the resulting HTML structure.
class
adds CSS class(es) - same as for normal HTML tags.
style
adds CSS styles - same as for normal HTML tags.
width
determines the desired width for the player. The aspect ratio is preserved while scaling, if know (see $wgPlayerVideoResolutionDetector). If both width and height are given, a box-fit is applied.
height
determines the desired height for the player. The aspect ratio is preserved while scaling, if know (see $wgPlayerVideoResolutionDetector). If both width and height are given, a box-fit is applied.
align
determines the alignment. Thre are four possible values:
  • none: (default): the player box creates a paragraph.
  • center: the player box creates a centered paragraph.
  • left: the player box floats on the left side, text flows around it.
  • right: the player box floats on the right side, text flows around it.
thumb
determines the thumbnail image (if any). Must be the name of an uploaded image.
forcegeneric
use the template registered under the "generic" key, instead of selecting a template by the file's type.

Any additional attributes are passed on as template parameters. So, if you give foo="test" as an attribute, a template may refer to that value using {{{foo}}}. Note that user parameters are always escaped before being passed to the template, to avoid HTML injection issues.

Some attributes supported by some templates (in the hope the user's plugin will understand them): loop, menu, scale, and quality.