Jump to content

Automated xml playlist problems


alxsmth

Recommended Posts

I have a script that uploads mp3s to a server and then writes uploaded mp3s to an xml playlist. The problem I have is that the xml playlist is in the wrong format for mp3 player I am using. I have tried to alter the formatting but everytime i change something everything stops working, i really need to get this working and i am starting to loose my sanity! Can anyone please help? I enclose all the neccesary information below, please post if more is needed or if im not making any sense!

 

The code, at present, for the updating of the xml is as follows:

 

/************************************************************

*    List Files/Update XML

************************************************************/

$handle=opendir($upload_dir);

$filelist = "";

$stringdata .= "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";

$stringdata .= "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n <tracklist>\n";

while ($file = readdir($handle)) {

  if(!is_dir($file) && !is_link($file)) {

      $filelist .= "<tr><td><sub><small><small><font color=grey>  ".date("d-m H:i", filemtime($upload_dir.$file))

                  ."</font></small></small></sub></td>

    <td><a href='$upload_dir$file'>".$file."</a>";

      if (!$DELETABLE)

$filelist .= "</td><td>Not Supported</td></tr>";

      if ($DELETABLE)

        $filelist .= "</td><td><center><a href='?del=$upload_dir".urlencode($file)."' title='delete'>x</a></center></td></tr>";

$stringdata .= "\n  <track>\n  <annotation>".str_replace(".mp3","",$file)."</annotation>\n    <location>$url_dir/$upload_dir$file</location>\n";

if ($info == "yes")

{$stringdata .= "    <info>$url_dir$upload_dir$file</info>\n";}

if (file_exists(str_replace(".mp3",$ingfilecheck,$file)))

{$stringdata .= "      <img>$url_dir$upload_dir".str_replace(".mp3",".jpg",$file)."</img>\n";}

$stringdata .= "  </track>";

}

}

$stringdata .= "\n\n </tracklist>\n

</playlist>";

$fh = fopen($savefile, 'w');

fwrite($fh, $stringdata);

fclose($fh);

 

This script creates the following xml playlist

 

<?xml version="1.0" encoding="UTF-8" ?>

<playlist version='1' xmlns='http://xspf.org/ns/0/'>

<tracklist>

 

  <track>

  <annotation>01 Intro - Inhale</annotation>

    <location>http://www.blazecheerleaders.co.uk/soundarchitect/files/01 Intro - Inhale.mp3</location>

  </track>

  <track>

  <annotation>talltom</annotation>

    <location>http://www.blazecheerleaders.co.uk/soundarchitect/files/talltom.mp3</location>

  </track>

 

</tracklist>

 

</playlist>

 

My mp3 player requires the format of the xml to be as follows

 

<?xml version='1.0' encoding='utf-8'?>

 

<songs>

 

<song url="files/Inhale.mp3" name="intro" />

 

<song url="files/talltom.mp3" name="talltom" />

 

</songs>

 

Thanks again in advance

 

 

Link to comment
https://forums.phpfreaks.com/topic/48443-automated-xml-playlist-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.