Hello all... I've been trying to build an XSPF (XML Shareable Playlist Format) Player plugin for for the last 2 days without getting anywhere. I though I would ask for advice.
I was tipped off about XSPF player by someone on here called signup.It's a flash music player that reads XSPF files.
You can download it here:
www.thefword.fm/xspf_player-0.2.2.zip
and read about it here:
musicplayer.sourceforge.net/
I then searched around a bit and found a php script that will convert all the mp3 files in a specified folder into an XSPF playlist.
You can download and read about it here:
www.dreden.com/2005/06/01/xspf-playlist-generator/
[code:1]<?php
#####################################################################
#
#
# Automatic XSPF Playlist generator PHP Script v1.2
#
# Script made by dreden (Odd Marthon Lende)
# Downloaded from
www.dreden.com
#
# If you want to sort your music by number you need to add the number to the beginning of the filename
#
#
#########################
// options
// Reverse the playlist by default. Set to true if yes.
$reverse = false;
// Shuffle the playlist by default. Set to true if yes.
$shuffle = false;
// use getid3() or use the old method to get artist and titles?
$useid3 = false;
$getid3file = "getid3/getid3.php";
// the directory that contains the music files
$musicdir = "./musikk";
// the url path to the music directory
$path = "
www.dreden.com/music/
";
// want to give listeners the ability to download the songs? set to true if yes or false if no
$download = true;
// what to remove from the title, so it looks nice?
// this is not use if $useid3 = true;
$cleanuptitle = array('/www.dreden.com-/', '/.mp3/');
// if you have $cleanuptitle = array('/string1/', 'string2', 'string3'); above, you need to set this to $cleanup = array('', '', '');
// or anything else you want the strings above to be replaced with.
// This is not use if $useid3 = true;
$cleanup = array('', '');
// self explained
$image = "
www.dreden.com/images/about_me.jpg
";
$creator = "Odd Marthon Lende";
$infourl = "
www.dreden.com/music/
";
$annotation = "
www.dreden.com/
";
$title = "Dredens Music on dreden.com";
// end options
### NO NEED TO EDIT BELOW THIS LINE ###
if ($useid3) {
require_once($getid3file);
$getID3 = new getID3;
}
if (is_dir($musicdir)) {
$i = 0;
print ('<?xml version="1.0" encoding="UTF-8" ?>
<playlist version="0" xmlns="
xspf.org/ns/0/
">
<title>' . $title . '</title>
<annotation>' . $annotation . '</annotation>
<creator>' . $creator . '</creator>
<info>' . $infourl . '</info>
<location>');
print 'http://';
print $_SERVER;
print $_SERVER;
print ('</location>
<trackList>' . "\n" . "\n" . "\n"«»);
if ($handle = opendir($musicdir)) {
while (false !== ($file = readdir($handle)))
{
if ($file == "."«») { $file = ""; } elseif ($file == ".."«») { $file = ""; }
else {
$audiofile[$i] = $file;
$i++;
}
}
closedir($handle);
}
if (isset($_REQUEST)) {
$reverse = $_REQUEST;
}
if (isset($_REQUEST)) {
$shuffle = $_REQUEST;
}
sort($audiofile);
if ($reverse) {
}
else {
rsort($audiofile);
}
if ($shuffle) {
shuffle($audiofile);
}
reset($audiofile);
for($j = 0; $j < count($audiofile); $j++) {
if($useid3) {
$filename = "$musicdir" . "/" . "$audiofile[$j]";
$fileinfo = $getID3->analyze($filename);
}
else {
$songtitle = preg_replace($cleanuptitle, $cleanup, $audiofile[$j]);
$songtitle = eregi_replace("_", " ", $songtitle);
$songtitle = eregi_replace("-", " ", $songtitle);
}
print "<track>" . "\n";
print ("<location>" . $path . $audiofile[$j] . "</location>" . "\n"«»);
if ($download) {
print ("<download>" . $path . $audiofile[$j] . "</download>" . "\n"«»);
}
print ("<image>" . $image . "</image>" . "\n"«»);
if ($useid3) {
print ("<annotation>" . $fileinfo . " - " . $fileinfo . "</annotation>" . "\n"«»);
}
else {
print ("<annotation>Dreden - " . $songtitle . "</annotation>" . "\n"«»);
}
print ("<info>
www.dreden.com/music/
" . "\n"«»);
print ("</track>" . "\n" . "\n"«»);
}
print ('
</trackList>
</playlist>');
}
else {
echo "<font color=\"red\"><center><h2>ERROR:<br>\nthe directory $musicdir can not be found\n<br>please check your configuration</h2></center></font>";
}
?> [/code:1]
You embed the flash movie using html and reference the xspf_playlist.php file as in the url as though it was a playlist.
[code:1]<object classid=â€clsid:«»D27CDB6E-AE6D-11cf-96B8-444553540000″ codebase=â€http://download.macromedia.com/pub/shockwave/
cabs/flash/swflash.cab#version=6,0,29,0″ width=â€184″ height=â€170″>
<param name=â€movie†value=â€http://server.com/xspf_player.swf?playlist_url=http://server.com/xspf_playlist.phpâ€>
<param name=â€quality†value=â€highâ€><param name=â€BGCOLOR†value=â€#D5D5D5″>
<embed src=â€http://server.com/xspf_player.swf?playlist_url=http://server.com/xspf_playlist.php†width=â€184″ height=â€170″ quality=â€high†pluginspage=â€http://www.macromedia.com/go/getflashplayer†type=â€application/x-shockwave-flash†bgcolor=â€#D5D5D5″>
</embed>
</object>[/code:1]
I'm afraid if you read all this way there is no solution... I've never used php before and I'm new to Joomla as well. This is about as far as I got!
We run an online radio station and plan to allow bands/artists that use our site to have a player on their cb profile page to showcase their own music. Like My Space.
All the songs will be reviewed by site admin so frontend uploading is not required. Admin could FTP the mp3's into a directory which could be named after each user id.
I know everyone is busy but I only got as far as creating a blank tab but couldn't even figure out how to embed the flash movie on the tab... let alone modifying the playlist script to check a folder based on the user id.
Could anyone describe how they would go about integrating this script and the xspf player with community builder to allow members to have a music player on their profile.
Another idea is that the mp3 files could contain the joomla user id... i think the file name is parsed already...
Also.. there needs to be a way so that if no mp3 files are in the users directory then the tab doesn't show on the profile. We only want artists and bands to have a music player.
Any advice that anyone has would be appreciated very very very much.
and of course if anyone wants to just create the plugin that would be great as well!!
Post edited by: alistaircochrane, at: 2006/01/17 00:50
Post edited by: alistaircochrane, at: 2006/01/17 00:52
Post edited by: alistaircochrane, at: 2006/01/17 00:53