First we will need our Flash mp3 player. I am using the WebPod free ‘iPod-like’ player, also available in ’slim’, which can be displayed in white or black. This also comes with the popular swfobject and js-to-flash .js files to overcome IE embedding problems. Follow the included instructions to display the player on your website where you want it. I suggest doing this in a .php file to make things easier later on when we get to the playlist. Joomla has a mambot that is used to include .php files into content or modules which works great for this.
Next we need to setup the XML feed. Make a new .php file and set the path for this file in the flash script you already have. The feed needs to output a simple XML file for your detailed sont information and path. Below is an example of my XML feed .php file with the database connection information removed. Since I am using User Homepages 2, which saves the page information object as a string to the database, we have to first convert the string back into an object then into an array to properly call the data inside of it.
<tunes>
<?php
$query = “SELECT id, user_id, pagetitle, menutitle, pagedata from jos_uhp2_pages WHERE published = ‘1′ AND approved = ‘1′ AND pagetype=’4′ ORDER BY id DESC LIMIT 200″;
$result = mysql_query($query);
function object_to_array($obj) {
$_arr = is_object($obj) ? get_object_vars($obj) : $obj;
foreach ($_arr as $key => $val) {
$val = (is_array($val) || is_object($val)) ? object_to_array($val) : $val;
$arr[$key] = $val;
}
return $arr;
}
while ($row = mysql_fetch_assoc($result)) {
$pd_obj = unserialize($row[’pagedata’]);
$pd_ary = object_to_array($pd_obj);
foreach ($pd_ary[song_file] as $key=>$value)
{
if($value !== “”){
?>
<tune>
<mp3>http://smart-love.ca/media/uhp2/<?php echo $row[’user_id’].’/’.$value; ?></mp3>
<title><?php echo $pd_ary[song_title][$key]; ?></title>
<album><?php echo $pd_ary[song_album][$key]; ?></album>
<bitrate>192</bitrate>
<image><?php echo $pd_ary[song_image][$key]; ?></image>
<link>http://smart-love.ca/index.php?option=com_uhp2&task=viewpage&user_id=<?php echo $row[’user_id’]; ?></link>
</tune>
<?php
}
}
}
?>
</tunes>
For the play list just copy this page as a new .php file and modify the output to display instead the javascript links used to play the songs in the player. Use the include function to include this playlist.php file on the same page as the player. You should be done.