XSPF Player

From BorielWiki

Jump to: navigation, search

Contents

Introduction

The XSPF Player plugin allows you to embed Fabrizio's Macromedia XSPF Player within your wordpress pages, either in your template or into your posts and pages, allowing you to play background MP3 music.

This player is licensed BSD, and it's bundled along the Wordpress plugins files.

This plugin is compatible with WordPress 2.0 

The plugin has been verified to work with WordPress up to current version (2.2).

Installation

To install de plugin, please go to the Plugin's page, and download the latest version. You should get the latest version unless you're having some problem with it.

Requirements

To install the plugin, you will need:

  • WordPress 1.5.2 or 2.0, WordpressMU
  • PHP 4.3.x (Recommended 5.x)
  • MySQL 4.x

If you're already using WordPress for your blog, then you will be (for sure) using PHP 4.3.x. MySQL is the database used by WordPress to store your post. If you are not sure, ask your ISP which version is installed in your host.

Installing the plugin

  1. Upload the .zip file content to your plugins folder, usually
    wp-content/plugins/
    . After this, you should have the file wp-content/plugins/xspf_player.php and the folder wp-content/plugins/xspf_player, with some other files.
  2. Activate the plugin on the plugin screen

You're done. To verify your installation, go to your admin panel and check to see if the 'XSPF Player' options menu is there. (Usually under Options-->xspf player)

The songs are added to your playlist through the WordPress back end as well. Go to Manage-->xspf to specify track url and track information.

Usage

Global mode

Once you have installed the plugin, you have to populate your database with MP3 URLs. Those MP3 can be stored both in your host or in another one. This is done through the plugin management tab on the WordPress admin page.

When the player is launched (embedded) in your site, it searches those MP3 (by theirs URLs) to play them. There are a few different ways you can embed the player into your site. The recommened way is by creating a new template wordpress page (see http://codex.wordpress.org/Pages#Page_Templates). On this new page you will include the PHP code to pull in the player.

Example:

<?php xspf_player::start('playlistname'); ?>

Of course, this can be put inside a div box to align the player as you wish.

Inline (on the fly) mode

To insert the player inside a post or page just click the [Xspf] button, or type the following:

[xspf]_start()[/xspf]

You can select a playlist (also called category in the management panel), inserting it into the parenthesis:

[xspf]_start('playlistname');[/xspf]

You can also use the older <xspf> tags, but the previous syntax is preferred:

<xspf>_start('playlistname');</xspf>

Advanced parameters

You can specify many params using the following syntax in your Wordpress post:

<xspf>_start(FALSE, 'param1=val1&param2=val2&…')</xspf>

Notice that the playlist has been replaced with the word FALSE (without quotes).


Alternatively, you can select a playlist and specify parameters.

<xspf>_start('playlistname', 'param1=val1&param2=val2&…')</xspf>
Note: Remember to turn off the 'visual editor' when specifying multiple parameters

For example, width and height can be changed on the fly inside body post, using this:

<xspf>_start(FALSE, 'width=300&height=120')</xspf>

This will display the player with 300 pixels width and 120 pixels height ignoring your default settings.

Note: Advanced parameter options override those configured in the Admin Panel.

Parameters list

There are many parameters, like:

  • autostart = true | false
Overrides autostart setup for the tracklist.
  • mode = 0 | 1 | 2 | 3 | 4
Selects player mode: 1=Button, 2=Slim, 3=Wide List,..
Mode 0 is a Special one. You can specify the URL of the .swf (Flash Player) file.
  • width
Player width in pixels
  • height
Player height in pixels

Additional Info

It’s already possible to play a single song (or a range of them) without having to define a category (e.g. see “Happy Christmas” post. I use it there). When invoking the plugin start() function, it’s possible (this is an undocumented feature) to use special hidden parameters, in that way:

Go to the management songs panel. In the tracks table you will see an number ID for each track. This number is unique. You can tell the player to play song number # (or a couple of them) without having to define a category.

E.g. to play song #3, just write the following into post or page:

<xspf>_start(FALSE, 'order=3')</xspf>

Will load song #3 only. Ranges are allowed using dash (-), and commas. E.g.:

<xspf>_start(FALSE, 'order=7,5,3-6,1')</xspf>

Will load song #7, #5, #3, #4, #5 (again), #6 and #1 in that order.

Personal tools