Supported Playlists

SUPPORTED PLAYLISTS

invisible | 02.01.2008 | print

Both the FLV Media Player and the Image Rotator have extensive playlist functionalities. Three commonly used formats are supported: XSPF (much used for CC music), RSS (much-used for Podcasts) and ASX (much-used on Windows servers).

Corresponding flashvars and tags

You can assign a playlist to the player with the file flashvar, just like a single mediafile. All item-specific flashvars, like image and link, can be set in a playlist as well. Here is a complete overview of these flashvars and their corresponding XSPF, RSS and ASX tags:

XSPF exampleRSS exampleASX example
FlashvarXSPF TagRSS TagASX Tag
file<location><media:content><ref>
image<image><media:thumbnail><param name="image">
id<identifier><guid><param name="id">
link<info><link><moreinfo>
type<meta rel="type"><media:content><param name="type">
captions<meta rel="captions">-<param name="captions">
audio<meta rel="audio">-<param name="audio">
title<title><title><title>
author<creator><author><author>

Note that the title and author flashvars are undocumented: they are simply not displayed when playing a single file. Also, audio and captions flashvars don't have an RSS reprentation; there's simply no tag for them.

Common pitfalls

I'd like to point out two common pitfalls users encounter when using playlists. First, always try to use full URL's (including the http:// part) when referring to files, links or images in your playlists. It will save you a lot of troubles with unresponsive SWF's or "file not found" errors! Nine out of ten times this is because the relative-url setup isn't working. Note that the Flash plugin checks for image and MP3 files relative from the HTML page and for FLV files relative from the SWF file!

Second, a playlist should always reside on the same server as the SWF file, due to security restrictions of the Flash Player. This can be solved if you own the domain on which the mediafiles reside. You then have to put a crossdomain.xml file in the root webfolder of that server. In this file, you can specifically allow sites to load data. An example is the crossdomain file from Youtube.

Auto-generating playlists

It's quite easy to autogenerate playlists serverside and then assign them to the player. You won't have to change the extension to .xml, since the player and rotator by default assume that the file flashvar is a playlist. Here's an example PHP script that autogenerates a playlist from MSQL:

// first connect to database
$dbcnx = @mysql_connect("localhost","USERNAME","PASSWORD");
$dbselect = @mysql_select_db("DATABASE");

// next, query for a list of titles, files and links.
$query = "SELECT title,file,link FROM mp3_table";
$result = mysql_query($query) or die('Error: '.mysql_error());

// third, build the playlist
header("content-type:text/xml;charset=utf-8");
echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n";
echo "<trackList>\n";
while($row = @mysql_fetch_array($result)) {
  echo "\t<track>\n";
  echo "\t\t<title>".$row['title']."</title>\n";
  echo "\t\t<location>".$row['file']."</location>\n";
  echo "\t\t<info>".$row['link']."</info>\n";
  echo "\t</track>\n";
}
echo "</trackList>\n";
echo "</playlist>\n";

If this file is called playlist.php, you can simply state file=playlist.php in your flashvars, and the PHP file will be requested and executed.

URL: http://www.jeroenwijering.com/?item=Supported_Playlists