Extension:MP3MediaHandler

From Linux Web Expert

Revision as of 04:41, 23 February 2024 by imported>Ciencia Al Poder (Reverted edits by Sonujainahir (talk) to last version by Clump)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

MediaWiki extensions manual
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
Quarterly downloads Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Public wikis using Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Translate the MP3MediaHandler extension if it is available at translatewiki.net

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.

Requirements

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.

Installation

  • Make sure that the required software is installed before you continue!
  • <translate> [[<tvar name=2>Special:ExtensionDistributor/MP3MediaHandler</tvar>|Download]] and move the extracted <tvar name=name>MP3MediaHandler</tvar> folder to your <tvar name=ext>extensions/</tvar> directory.</translate>
    <translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/MP3MediaHandler
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    wfLoadExtension( 'MP3MediaHandler' );
    
  • Configure as required. (see also the examples provided)
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>

Configuration

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

Usage

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

Specific Flash players

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 Player

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