Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-22-2008, 08:25 PM   PM User | #1
mattsnow
New to the CF scene

 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mattsnow is an unknown quantity at this point
Post XSPF generator

I am trying to use this player to play music on my site and it works fine, as you can see here. this is great for just a few songs, but i have about 300 here that have been uploaded and it would be an extremely boring task to add each song to the xspf playlist file. Does anyone know about a playlist generator or something that can take the .mp3 files name and put it in the playlist file?
mattsnow is offline   Reply With Quote
Old 05-22-2008, 08:28 PM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
If you know the format of the xml file that is needed then you can use php to generate the xml file for you.
PHP Code:
<?php
/*
This is a sample file that reads through a directory, filters the mp3/jpg/flv 
files and builds a playlist from it. After looking through this file, you'll 
probably 'get the idea' and'll be able to setup your own directory.
*/


// search for mp3 files. set this to '.flv' or '.jpg' for the other scripts 
$filter ".mp3";
// path to the directory you want to scan
$directory "somedirectory";


// read through the directory and filter files to an array
@$d dir($directory);
if (
$d) { 
    while(
$entry=$d->read()) {  
        
$ps strpos(strtolower($entry), $filter);
        if (!(
$ps === false)) {  
            
$items[] = $entry
        } 
    }
    
$d->close();
    
rsort($items);
}

// third, the playlist is built in an xspf format
// we'll first add an xml header and the opening tags .. 
header("content-type:text/xml;charset=utf-8");

echo 
"<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n";
echo 
"    <title>Sample PHP Generated Playlist</title>\n";
echo 
"    <info>http://www.*******************/</info>\n";
echo 
"    <trackList>\n";

// .. then we loop through the mysql array ..
for($i=0$i<sizeof($items); $i++) {
    echo 
"        <track>\n";
    echo 
"            <title>".$filename."</title>\n";
    echo 
"            <location>$items[$i]</location>\n";
    echo 
"        </track>\n";
}
 
// .. and last we add the closing tags
echo "    </trackList>\n";
echo 
"</playlist>\n";


/*
That's it! You can feed this playlist to the SWF by setting this as it's 'file' 
parameter in your HTML page.
*/

?>
The above code IS the xml file so link to that as the playlist. Just change the directory to match where your mp3 files are stored at.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||

Last edited by _Aerospace_Eng_; 05-24-2008 at 06:53 PM..
_Aerospace_Eng_ is offline   Reply With Quote
Old 05-24-2008, 05:22 PM   PM User | #3
mattsnow
New to the CF scene

 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mattsnow is an unknown quantity at this point
Thumbs up

This looks like what I'm looking for, although I'm a bit confused on what exactly you do. Could you post more detailed instructions?
mattsnow is offline   Reply With Quote
Old 05-24-2008, 06:51 PM   PM User | #4
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
You change the directory of where the mp3s are stored at. You also need to know how a playlist looks for the player. As I said you NEED to know the structure of the playlist. Do you know this? If so then post an example.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 12-22-2008, 08:14 AM   PM User | #5
siggma
New to the CF scene

 
Join Date: Dec 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
siggma is an unknown quantity at this point
Thumbs up A new XSPF.PHP playlist generator

I'm very new to PHP. My first project is an almost valid xspf playlist generator that scans a directory and generates an xml (xspf) playlist from the id3 tags it finds in mp3 files. This project uses the get_id3() class available at sourceforge.net.

An html title is provided for search engines as well as a default "noimage.jpg" used for all mp3s without a matching jpg image. JPG Images that match the mp3 file name are included in the playlist making it easy to set a default image for an entire directory and customize images for individual tracks.

You can get it here: xspf.php playlist generator home page

Any comments are welcome.
-Tom
siggma is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:12 PM.


Advertisement
Log in to turn off these ads.