Open main menu

Extension:MP3MediaHandler

MediaWiki extensions manual
OOjs UI icon advanced.svg
MP3MediaHandler
Release status: beta
Implementation Media
Description Adds a media player for mp3 files on the wiki.
Author(s) Mark Clements (HappyDogtalk)
Latest version 1.0.0 (2016-02-11)
MediaWiki 1.23+
PHP 5.3+
Database changes No
License No license specified
Download
Translate the MP3MediaHandler extension if it is available at translatewiki.net
Check usage and version matrix.

The MP3MediaHandler extension allows any .mp3 files that have been uploaded to be playable via an in-browser audio player. It uses the HTML5 <audio> tag if supported, with a fallback to a direct file link (which the browser will either play natively, open in a local media player or prompt the user to download).

In addition, it is possible to install a Flash-based media-player as an alternative fallback, so if the browser supports Flash, but not the <audio> tag, then it will use this before falling-back to the native browser behaviour.

RequirementsEdit

There are no essential requirements, but if you want to offer Flash as a fallback then you will need to download an appropriate Flash media player. Some examples are given below but any Flash player that supports mp3 playback may be used.

InstallationEdit

  • Make sure that the required software is installed before you continue!
  • Download and place the file(s) in a directory called MP3MediaHandler in your extensions/ folder.

To users running MediaWiki 1.24 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension(). If you need to install this extension on these earlier versions (MediaWiki 1.24 and earlier), instead of wfLoadExtension( 'MP3MediaHandler' );, you need to use:

require_once "$IP/extensions/MP3MediaHandler/MP3MediaHandler.php";

ConfigurationEdit

Variable name Default value Description
$wgFlashPlayerPath (not set) The URL (absolute, or relative to the wiki entry-point) of the .SWF file for the Flash player. If not set, then no Flash-based fallback is provided.
Flash Configuration (Only relevant if $wgFlashPlayerPath is set.)
$wgFlashPlayerURLParam "url" The name of the parameter that will be used to pass the media-file URL to the SWF.
$wgFlashPlayerParams array() An array of key => value pairs of additional Flash configuration parameters. These will be added as <param> tags.
$wgFlashPlayerFlashVars array() An array of key => value pairs of additional parameters that you need to pass to the SWF file. These will be output in the FlashVars <param> tag, along with the URL parameter defined above (so do not include that parameter in this array).
$wgFlashPlayerWidth (not set) These two variables may be set to control the width/height of the Flash player. If either is omitted then no value will be set, so the default Flash movie size will be used.
$wgFlashPlayerHeight

UsageEdit

Just make a wikilink to the MP3 file e.g. [[File:12ToccataAndFugueInDMinor_vbr.mp3]].

Specific Flash playersEdit

This section holds example configurations for popular Flash players that support mp3 files. Please add your own example configuration for any popular players not on this list.

Note that you only need to install/configure a fall-back Flash player if you need to support older browsers that haven't implemented the <audio> tag for .mp3 files.

All examples assume the SWF file is placed in your root wiki folder. If it is located elsewhere then you will need to update $wgFlashPlayerPath appropriately.

Mini MP3 PlayerEdit

$wgFlashPlayerPath = "player_mp3_mini.swf";
$wgFlashPlayerURLParam = "mp3";
$wgFlashPlayerParams = array(
        'bgcolor' => "#5a5757",
);
$wgFlashPlayerHeight = "20";