Community Documentation

Creating playlists (eg. xml files) on the fly

Last updated October 11, 2010. Created by Shai on May 13, 2007.
Edited by verta, matt2000, Stuart Greenfield, Wolfflow. Log in to edit this page.

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 its 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.

About this page

Drupal version
Drupal 5.x, Drupal 6.x

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here