Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: XSPF generator

  1. #1
    New to the CF scene
    Join Date
    May 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    Last edited by _Aerospace_Eng_; 05-24-2008 at 07:53 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    May 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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!||||

  • #5
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •