Creating playlists (eg. xml files) on the fly

Last modified: March 9, 2009 - 08:38

What is a playlist?

A "playlist" is a general term for set of files which are displayed together or in sequence by a Flash player. It could be a list of videos, MP3s, images, or a mix of these. Within SWF Tools they take the form of a general structured list of data that will eventually find it's way into an XML file.

Displaying a list of files as a playlist

SWF Tools provides a useful function for generating playlist data: swftools_prepare_playlist_data(). This is really useful for quick results where you have a list of files and you just want to push them out. Once you have your playlist data, you can then pass it to a variation of the swf() function called swf_list().

<?php
// Generate some playlist data which is compatible with SWF Tools.
$playlist swftools_prepare_playlist_data(array('image1.jpg', 'image2.jpg'));

// Pass the playlist data to the playlist display function.
print swf_list($playlist);

// REMEMBER, that swf_list bahaves like swf(), so you can
// do all the same tricks with flashvars and params.
print swf_list($playlist, '400x300');
?>

Note - as of SWF Tools 6.x-2.0 it is not necessary to call the prepare function separately. Just call swf() directly with an array of files, and SWF Tools will take care of everything automatically.

So

<?php
$files
= array('image1.jpg', 'image2.jpg');
print
swf($files);
?>

Will work fine.

The title says "Creating

goose2000 - July 24, 2009 - 18:59

The title says "Creating playlists (eg. xml files) on the fly"

But I see no mention of loading xml playlists dynamic or not, at all on this page.
Also, how about an example of just loading a plain static xml file into swf tools?

 
 

Drupal is a registered trademark of Dries Buytaert.