Media Players

From EIRMA Wiki

Jump to: navigation, search
Quick Links

Overview and Tutorial


Pre-Installation

Installation

Post-Installation


Administration


Moderation


Design


Advanced


Other

Contents


Introduction

LDM provides a range of features for handling audio and video media. The in-built Jukebox integrates with Jeroen Wijering's JW Media Player, Windows Media Player, Real Player, DivX and Quicktime, and has add-on 'extras' that integrate with the various Wimpy players (Wimpy, WimpyButton and Wasp). New players can be added by the administrator.

JW Player in Jukebox
Wimpy Button used in main linkbit

By default, media are played in a Jukebox, which can be configured to launch as a separate pop-up window or within the main LDM display. Installable extras (see below) integrate the JW Media Player and the WimpyButton directly into the main display entrybits, or [version 2.3.0] place the Jukebox within the Shadowbox lightbox.

Configuration settings control which players handle which filetypes, work on specific user PC operating systems, etc. Since more than one player can often handle a given file, the settings define the priority of each player for each file type. LDM select the player with the highest priority capable of handling a given media file and operating system.

In order for LDM to recognise that an entry points to a media file, the vBulletin file attachments table must contain mimetype information for its filetypes: LDM will not launch its media player for filetypes where this information is missing. (In that situation, the user's PC may launch a player itself - for example, when an mp3 file is downloaded, Windows Media Player may launch automatically and play the file. This is outside LDM's control.) See Configuring Filetypes in vBulletin for information on setting up mimetype information.

Default File Handling

By default, mp3 and flv files are played using Jeroen Wijering's media player.

When a user has a Windows box:

  • mpg, mpeg, wmv, asf, wma, avi, and wav files are played using Windows Media Player
  • mov and qt files are played using QuickTime
  • ra, ram, rm, rmvb, rpm, rv files are played using Real Player

On Macs:

  • mp3, wma, wav, mov, qt, mpg, mpeg, wmv, swf, asf, avi files use QuickTime
  • ra, ram, rm, rmvb, rpm, rv files use Real Player

On Linux boxes:

  • mpg, mpeg, avi, mov, qt, ra, ram, rm, rmvb, rpm, rv use Real Player

Jukebox Control Settings

The main Jukebox control parameters are edited on the LDM->admin->settings page. These settings define whether the Jukebox should launch in a popup window or in the main browser window, and specify its size and some other parameters.

Player Control Settings

The detailed media player control parameters are edited on the LDM->admin->media players page. Normally, you do not need to change any of these settings, with the possible exception of the Player Priority, in order to change which player launches for a given filetype.

The accompanying image illustrates the standard settings for the in-built Windows Media Player.

Windows Media Player control settings

The first group of settings are quite self-explanatory:

Enabled 
Whether this player is active or not
Filetypes handled 
List of filetypes handled by player, e.g. mpg, mpeg, etc. Each of these filetypes must also appear in the vBulletin admincp attachments table with valid mimetype information (Configuring Filetypes in vBulletin).
Player priority 
Integer, the higher the value, the greater the player's precedence compared to other players that are in principle capable of handling the same media file
Operating systems 
One or more of Windows/Mac/Linux on which the player works - this refers to the user's machine, not the server.

The following settings are more technical:

Playbit template 
The vBulletin template used to display the media player. This template usually consists of a sequence of commands within <OBJECT> and/or <EMBED> tags, with parameters that identify the media stream, player size, etc.
Urlencode 
Whether to urlencode the url defining the media delivery stream. Typically required for Javascript-based media players.
Settings
Additional settings to be passed to the playbit template, in the form of a comma-separated series of string assignment statements, example player_width="320", player_height="240", (note, no dollar signs). These are transformed into php variables within the playbit template, in this case $player_width and $player_height.
Delivery 
stream, url or fullurl, where stream tells LDM to deliver the file contents as a byte stream to the player, url means to provide a url relative to the script and fullurl means to provide a fully-qualified url. When possible, streaming is preferred, as it enables more sophisticated media players to jump rapidly between sections parts of the media file and also keeps secret the location of the media file. Hohwever, some media players only work with an explicit url to the media file.
Playerbit function
Name of a php function which will be used during the pre-processing stages prior to constructing the playbit. Not normally required. See example 2: Flash Video Sites
Playerid function
Name of a php function which will be used during pre-processing stages in order to identify whether the current player should handle a given media file. Not normally required. See example 2: Flash Video Sites.

Adding New Players

Adding a new media player required the following steps:

  • write a plugin to define and install the new player and tie this to an appropriate hook in LDM (usually ldm_playme_initplayers but see below)
  • write and install the accompanying playbit template
  • if necessary, provide supporting functions to handle the media file

Media File Extras

The release contains several add-ons to extend the Jukebox:

  • flashsites handles a range of flash video files such as YouTube
  • wimpy enables use of the Wimpy media player for mp3s and flash videos
  • add-mimetypes 'autocreates' mimetype entries in vBulletin for a wide range of media filetypes
  • JW-player-extensions enables use of the [www.jeroenwijering.com/ Jeroen Wijering] Silverlight media player for wmv/wma files; small in-line media players within the entrybits and the possibility to interpret xml files as playlists
  • shadowbox enables players to appear in a overlaid shadowbox, with controls to move smoothly between tracks

See Add-on Extras for more information.

Detailed Examples

1: Wimpy Jukebox

The Wimpy Jukebox player (provided in the extras directory) defines the following plugin:

$wimpy_player = array(
	"name" => "Wimpy",
	"priority" => 99,
	"enabled" => 1,
	"filetypes_played" => "mp3",
	"playerbit" => "links_playerbit_Wimpy",
	"opsys" => array( "Windows"=>1, "Linux"=>1, "Mac"=>1, ),
	"vars" => array( ),
	"player_stream" => "stream",
	"urlencode" => 1,
	);
add_ldm_player($wimpy_player);

and ties this to the ldm_playme_initplayers hook to create a high-priority player for handling mp3 files on all available operating systems. The mp3 media content is streamed via LDM and the source identified as a urlencoded string.

This is the accompanying links_playerbit_Wimpy template:

<script language="JavaScript" type="text/javascript" src='clientscript/wimpy.js'></script>
<script language="JavaScript" type="text/javascript" >
	makeWimpyPlayer("$player_stream");
</script>

The player also requires other code provided by Wimpy: the wimpy.swf Flash code, some accompanying Javascript and php routines taken from the [| getid3] public library. These are uploaded into appropriate forum directories.

2: Flash Video Sites

Extras/flash-sites provides plugins to handle a range of Flash-based video download sites like YouTube. With these sites, the url that the user sees/provides is generally not a direct url to the Flash media file, so it is necessary to process the user's url in order to extract this information. This is where the playerid_func and playerbit_func routines come in.

This is the plugin tied to ldm_playme_initplayers

$flash_player = array(
	"name" => "FlashSite",
	"priority" => 50,
	"enabled" => 1,
	"filetypes_played" => "",
	"playerbit" => "links_playerbit_FlashSites",
	"opsys" => array( "Windows"=>1, "Linux"=>1, "Mac"=>1, ),
	"vars" => array( "player_width" => 480, "player_height" => 360, ),
	"playerid_func" => "ldm_FlashSite_id",
	"playerbit_func" => "ldm_FlashSite_bit",
	"urlencode" => 0,
		);
add_ldm_player($flash_player);
require_once(DIR . '/includes/local_links_flashsites.php');

Similar to the Wimpy Player plugin, this also specifies playerid_func and playerbit_func and pulls in the php code for these functions from the includes/local_links_flashsite.php file.

All the hard work is done within these functions, to work out for each preset site (YouTube, Sharkle, etc) the Flash file corresponding to the entered url. This is generally done by grabbing the contents of the original url and processing it through a regular expression. Take a look at includes/local_links_flashsites.php for details.

3: Wimpy Button

The Wimpy Button addin takes another approach, bypassing the Jukebox player and replacing the filetype icon in the main linkbit with a Wimpy button to play the accompanying mp3 file.

This is the plugin, in this case tied to the ldm_linkbit_create hook:

if ($is_musicbox and $lc_urlType=="mp3") {
	$wimpy_url = mk_file_name($vbulletin->options['bburl'], 
		"local_stream.php?action=stream&linkid=".$linkid."&catid=".$linkcatid);
	$encode_url = urlencode($wimpy_url);
	$encode_src = mk_file_name($vbulletin->options['bburl'], 
		"getid3/wimpy_button.swf?theFile=".$encode_url);
	$linkurljump = $linkname;
	eval("\$linktypebit = \"".fetch_template('links_playerbit_WimpyButton', 0, 0)."\";");
}

and this is the links_playerbit_WimpyButton template:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,47,0"
width="20"
height="15"
name="wimpybutton138"
id="wimpybutton138"
>
	<param name="movie" value="$encode_src" />
	<param name="loop" value="false" />
	<param name="menu" value="false" />
	<param name="quality" value="high" />
	<param name="bgcolor" value="#FFFFFF" />
	<param name="flashvars" value="theFile=$encode_url&playingColor=0000FF&buttonStyle=square&bufferAudio=10" />
	<embed src="$encode_src"
	flashvars="theFile=$encode_url&playingColor=0000FF&buttonStyle=square&bufferAudio=10"
	width="20"
	height="15"
	bgcolor="#FFFFFF"
	loop="false"
	menu="false"
	quality="high"
	name="wimpybutton138"
	id="wimpybutton138"
	align="middle"
	allowScriptAccess="sameDomain"
	type="application/x-shockwave-flash"
	pluginspage="http://www.macromedia.com/go/getflashplayer"
	/>
</object>
 
Personal tools