summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2009-02-28 18:13:48 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2009-02-28 18:13:48 +0000
commitdbdd96ed1b3b00a850be001f3dbeea3273739a98 (patch)
treeccd23afffb6a4c2dc185bd6ffc39e13435fc1179 /lib
parent3a3e0c6a9f72d5031a4025dedcf2360c497c4953 (diff)
downloadampache-dbdd96ed1b3b00a850be001f3dbeea3273739a98.tar.gz
ampache-dbdd96ed1b3b00a850be001f3dbeea3273739a98.tar.bz2
ampache-dbdd96ed1b3b00a850be001f3dbeea3273739a98.zip
unify how the stream is constructed and played, this is a major change might be some regressions
Diffstat (limited to 'lib')
-rw-r--r--lib/class/catalog.class.php2
-rw-r--r--lib/class/democratic.class.php15
-rw-r--r--lib/class/localplay.abstract.php12
-rw-r--r--lib/class/media.interface.php2
-rw-r--r--lib/class/radio.class.php53
-rw-r--r--lib/class/random.class.php11
-rw-r--r--lib/class/song.class.php52
-rw-r--r--lib/class/stream.class.php219
-rw-r--r--lib/class/tmpplaylist.class.php2
-rw-r--r--lib/class/xmldata.class.php52
-rw-r--r--lib/ui.lib.php13
11 files changed, 257 insertions, 176 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index e8f4638b..86dfc91e 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -2443,7 +2443,7 @@ class Catalog extends database_object {
$xml['dict']['Sample Rate'] = intval($song->rate);
$xml['dict']['Play Count'] = intval($song->played);
$xml['dict']['Track Type'] = "URL";
- $xml['dict']['Location'] = $song->get_url();
+ $xml['dict']['Location'] = Song::play_url($song->id);
echo xml_from_array($xml,1,'itunes');
// flush output buffer
} // while result
diff --git a/lib/class/democratic.class.php b/lib/class/democratic.class.php
index a8bd7456..9e72251a 100644
--- a/lib/class/democratic.class.php
+++ b/lib/class/democratic.class.php
@@ -239,23 +239,16 @@ class Democratic extends tmpPlaylist {
} // get_items
/**
- * get_url
+ * play_url
* This returns the special play URL for democratic play, only open to ADMINs
*/
- public function get_url() {
+ public function play_url() {
- $web_path = Config::get('web_path');
+ $link = Stream::get_base_url() . 'demo_id=' . scrub_out($this->id);
- if (Config::get('force_http_play')) {
- $port = Config::get('http_port') ? ':' . Config::get('http_port') : '';
- $web_path = str_replace("https://" . $_SERVER['HTTP_HOST'], "http://" . $_SERVER['SERVER_NAME'] . $port,$web_path);
- }
-
- $link = $web_path . '/play/index.php?demo_id=' . scrub_out($this->id) .
- '&sid=' . Stream::get_session() . '&uid=' . scrub_out($GLOBALS['user']->id);
return $link;
- } // get_url
+ } // play_url
/**
* get_next_object
diff --git a/lib/class/localplay.abstract.php b/lib/class/localplay.abstract.php
index e7baf0ef..3ab95388 100644
--- a/lib/class/localplay.abstract.php
+++ b/lib/class/localplay.abstract.php
@@ -59,17 +59,9 @@ abstract class localplay_controller {
return $object;
}
- // This can get a little complicated
- switch ($object_type) {
- case 'random':
+ $class = get_class($object);
- break;
- case 'radio':
- case 'song':
- default:
- $url = $object->get_url(Stream::get_session());
- break;
- } // end switch on objecttype
+ $url = call_user_func(array($class,'play_url'),$object->id);
return $url;
diff --git a/lib/class/media.interface.php b/lib/class/media.interface.php
index 8becafe4..14bbf9a7 100644
--- a/lib/class/media.interface.php
+++ b/lib/class/media.interface.php
@@ -28,7 +28,7 @@ interface media {
public function format();
public function native_stream();
- public static function play_url($oid,$sid='',$force_http='');
+ public static function play_url($oid);
public function stream_cmd();
public function has_flag();
diff --git a/lib/class/radio.class.php b/lib/class/radio.class.php
index ee3cf4aa..4bbd3a51 100644
--- a/lib/class/radio.class.php
+++ b/lib/class/radio.class.php
@@ -25,7 +25,7 @@
* This handles the internet radio stuff, that is inserted into live_stream
* this can include podcasts or what-have-you
*/
-class Radio extends database_object {
+class Radio extends database_object implements media {
/* DB based variables */
public $id;
@@ -70,16 +70,6 @@ class Radio extends database_object {
} // format
/**
- * get_url
- * This returns the URL for this live stream
- */
- public function get_url() {
-
-
-
- } // get_url
-
- /**
* update
* This is a static function that takes a key'd array for input
* it depends on a ID element to determine which radio element it
@@ -176,6 +166,47 @@ class Radio extends database_object {
} // delete
+ /**
+ * native_stream
+ * This is needed by the media interface
+ */
+ public function native_stream() {
+
+
+
+ } // native_stream
+
+ /**
+ * play_url
+ * This is needed by the media interface
+ */
+ public static function play_url($oid,$sid='',$force_http='') {
+
+ $radio = new Radio($oid);
+
+ return $radio->url;
+
+ } // play_url
+
+ /**
+ * has_flag
+ * This is needed by the media interface
+ */
+ public function has_flag() {
+
+
+
+ } // has_flag
+
+ /**
+ * stream_cmd
+ * Needed by the media interface
+ */
+ public function stream_cmd() {
+
+
+ } // stream_cmd
+
} //end of radio class
?>
diff --git a/lib/class/random.class.php b/lib/class/random.class.php
index 8c8a55e7..0863a60a 100644
--- a/lib/class/random.class.php
+++ b/lib/class/random.class.php
@@ -26,7 +26,7 @@
* by this class, there isn't a table for this class so most of it's functions
* are static
*/
-class Random {
+class Random implements media {
/**
* Constructor
@@ -91,7 +91,7 @@ class Random {
* This generates a random play url based on the passed type
* and returns it
*/
- public static function play_url($type) {
+ public static function play_url($type,$sid='',$force_http='') {
if (!$type = self::validate_type($type)) {
return false;
@@ -99,7 +99,7 @@ class Random {
$uid = $GLOBALS['user']->id;
- $url = Stream::get_base_url() . "random=1&type=$type&uid=$uid$session_string";
+ $url = Stream::get_base_url() . "random=1&type=$type&uid=$uid";
return $url;
@@ -442,6 +442,11 @@ class Random {
} // validate_type
+ public function native_stream() { }
+ public function stream_cmd() { }
+ public function has_flag() { }
+ public function format() { }
+
} //end of random class
?>
diff --git a/lib/class/song.class.php b/lib/class/song.class.php
index 536a76b2..3e1a124c 100644
--- a/lib/class/song.class.php
+++ b/lib/class/song.class.php
@@ -853,57 +853,25 @@ class Song extends database_object implements media {
* a stream URL taking into account the downsmapling mojo and everything
* else, this is the true function
*/
- public static function play_url($oid,$session_id='',$force_http='') {
+ public static function play_url($oid) {
-
- } // play_url
-
- /**
- * get_url
- * This function takes all the song information and correctly formats
- * a stream URL taking into account the downsampling mojo and everything
- * else, this is used or will be used by _EVERYTHING_
- */
- public function get_url($session_id='',$force_http='') {
-
- /* Define Variables we are going to need */
+ $song = new Song($oid);
$user_id = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1';
- $song_id = $this->id;
+ $type = $song->type;
- if (Config::get('require_session')) {
- if ($session_id) {
- $session_string = "&sid=" . $session_id;
- }
- else {
- $session_string = "&sid=" . Stream::get_session();
- }
- } // if they are requiring a session
-
- $type = $this->type;
+ // Required for some versions of winamp that won't work if the stream doesn't end in
+ // .ogg This will not break any properly working player, don't report this as a bug!
+ if ($song->type == 'flac') { $type = 'ogg'; }
- /* Account for retarded players */
- if ($this->type == 'flac') { $type = 'ogg'; }
-
- // Only reformat if we need to
- if (!isset($this->f_title)) {
- $this->format();
- }
+ $song->format();
- $song_name = rawurlencode($this->f_artist_full . " - " . $this->title . "." . $type);
+ $song_name = rawurlencode($song->f_artist_full . " - " . $song->title . "." . $type);
- $web_path = Config::get('web_path');
-
- //FIXME: REPLACE WITH Stream::get_base_url
- if (Config::get('force_http_play') OR !empty($force_http)) {
- $port = Config::get('http_port') ? ':' . Config::get('http_port') : '';
- $web_path = str_replace("https://" . $_SERVER['HTTP_HOST'], "http://" . $_SERVER['SERVER_NAME'] . $port,$web_path);
- }
-
- $url = $web_path . "/play/index.php?oid=$song_id&uid=$user_id$session_string$ds_string&name=/$song_name";
+ $url = Stream::get_base_url() . "/play/index.php?oid=$song_id&uid=$user_id$session_string$ds_string&name=/$song_name";
return $url;
- } // get_url
+ } // play_url
/**
* parse_song_url
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php
index 9de66510..ec8308e5 100644
--- a/lib/class/stream.class.php
+++ b/lib/class/stream.class.php
@@ -31,7 +31,7 @@ class Stream {
/* Variables from DB */
public $type;
public $web_path;
- public $songs = array();
+ public $media = array();
public $urls = array();
public $sess;
public $user_id;
@@ -46,10 +46,10 @@ class Stream {
* Constructor for the stream class takes a type and an array
* of song ids
*/
- public function __construct($type='m3u', $song_ids=0) {
+ public function __construct($type='m3u', $media_ids=0) {
$this->type = $type;
- $this->songs = $song_ids;
+ $this->media = $media_ids;
$this->web_path = Config::get('web_path');
$this->user_id = $GLOBALS['user']->id;
@@ -66,7 +66,7 @@ class Stream {
*/
public function start() {
- if (!count($this->songs) AND !count($this->urls)) {
+ if (!count($this->media) AND !count($this->urls)) {
debug_event('stream','Error: No Songs Passed on ' . $this->type . ' stream','2');
return false;
}
@@ -99,7 +99,12 @@ class Stream {
*/
public function manual_url_add($url) {
- $this->urls[] = $url;
+ if (is_array($url)) {
+ $this->urls[] = array_merge($url,$this->urls);
+ }
+ else {
+ $this->urls[] = $url;
+ }
} // manual_url_add
@@ -118,6 +123,19 @@ class Stream {
} // get_session
/**
+ * set_session
+ * This overrides the normal session value, without adding
+ * an additional session into the database, should be called
+ * with care
+ */
+ public static function set_session($sid) {
+
+ self::$session_inserted = true;
+ self::$session=$sid;
+
+ } // set_session
+
+ /**
* insert_session
* This inserts a row into the session_stream table
*/
@@ -225,15 +243,9 @@ class Stream {
asort($this->urls);
/* Foreach songs */
- foreach ($this->songs as $song_id) {
- // If it's a place-holder
- if ($song_id == '-1') {
- echo array_pop($this->urls) . "\n";
- continue;
- }
- $song = new Song($song_id);
- if ($song->type == ".flac") { $song->type = ".ogg"; }
- echo $song->get_url();
+ foreach ($this->media as $element) {
+ $type = array_shift($element);
+ echo call_user_func(array($type,'play_url'),array_shift($element)) . "\n";
} // end foreach
/* Foreach the additional URLs */
@@ -256,21 +268,29 @@ class Stream {
header("Content-Type: audio/x-mpegurl;");
echo "#EXTM3U\n";
- // Flip for the popping
- asort($this->urls);
-
// Foreach the songs in this stream object
- foreach ($this->songs as $song_id) {
- if ($song_id == '-1') {
- echo "#EXTINF: URL-Add\n";
- echo array_pop($this->urls) . "\n";
- continue;
+ foreach ($this->media as $element) {
+ $type = array_shift($element);
+ $media = new $type(array_shift($element));
+ $media->format();
+ switch ($type) {
+ case 'song':
+ echo "#EXTINF:$media->time," . $media->f_artist_full . " - " . $media->title . "\n";
+ break;
+ case 'video':
+ echo "#EXTINF: Video - $media->title\n";
+ break;
+ case 'radio':
+ echo "#EXTINF: Radio - $media->name [$media->frequency] ($media->site_url)\n";
+ break;
+ case 'random':
+ echo "#EXTINF:Random URL\n";
+ break;
+ default:
+ echo "#EXTINF:URL-Add\n";
+ break;
}
- $song = new Song($song_id);
- $song->format();
-
- echo "#EXTINF:$song->time," . $song->f_artist_full . " - " . $song->title . "\n";
- echo $song->get_url(self::$session) . "\n";
+ echo call_user_func(array($type,'play_url'),$media->id) . "\n";
} // end foreach
/* Foreach URLS */
@@ -289,23 +309,34 @@ class Stream {
public function create_pls() {
/* Count entries */
- $total_entries = count($this->songs) + count($this->urls);
+ $total_entries = count($this->media) + count($this->urls);
// Send the client a pls playlist
header("Cache-control: public");
- header("Content-Disposition: filename=ampache-playlist.pls");
+ header("Content-Disposition: filename=ampache_playlist.pls");
header("Content-Type: audio/x-scpls;");
echo "[Playlist]\n";
echo "NumberOfEntries=$total_entries\n";
- foreach ($this->songs as $song_id) {
+ foreach ($this->media as $element) {
$i++;
- $song = new Song($song_id);
- $song->format();
- $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type;
- $song_url = $song->get_url(self::$session);
- echo "File" . $i . "=$song_url\n";
- echo "Title" . $i . "=$song_name\n";
- echo "Length" . $i . "=$song->time\n";
+ $type = array_shift($element);
+ $media = new $type(array_shift($element));
+ $media->format();
+ switch ($type) {
+ case 'song':
+ $name = $media->f_artist_full . " - " . $media->title . "." . $media->type;
+ $length = $media->time;
+ break;
+ default:
+ $name = 'URL-Add';
+ $length='-1';
+ break;
+ }
+
+ $url = call_user_func(array($type,'play_url'),$media->id);
+ echo "File" . $i . "=$url\n";
+ echo "Title" . $i . "=$name\n";
+ echo "Length" . $i . "=$length\n";
} // end foreach songs
/* Foreach Additional URLs */
@@ -328,21 +359,31 @@ class Stream {
public function create_asx() {
header("Cache-control: public");
- header("Content-Disposition: filename=playlist.asx");
+ header("Content-Disposition: filename=ampache_playlist.asx");
header("Content-Type: audio/x-ms-wmv;");
echo "<ASX version = \"3.0\" BANNERBAR=\"AUTO\">\n";
echo "<TITLE>Ampache ASX Playlist</TITLE>";
- foreach ($this->songs as $song_id) {
- $song = new Song($song_id);
- $song->format();
- $url = $song->get_url(self::$session);
- $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type;
-
+ foreach ($this->media as $element) {
+ $type = array_shift($element);
+ $media = new $type(array_shift($element));
+ $media->format();
+ switch ($type) {
+ case 'song':
+ $name = $media->f_album_full . " - " . $media->title . "." . $media->type;
+ $author = $media->f_artist_full;
+ break;
+ default:
+ $author = 'Ampache';
+ $name = 'URL-Add';
+ break;
+ } // end switch
+ $url = call_user_func(array($type,'play_url'),$media->id);
+
echo "<ENTRY>\n";
- echo "<TITLE>".$song->f_album_full ." - ". $song->f_artist_full ." - ". $song->title ."</TITLE>\n";
- echo "<AUTHOR>".$song->f_artist_full."</AUTHOR>\n";
+ echo "<TITLE>$name</TITLE>\n";
+ echo "<AUTHOR>$author</AUTHOR>\n";
echo "<REF HREF = \"". $url . "\" />\n";
echo "</ENTRY>\n";
@@ -374,40 +415,41 @@ class Stream {
}
// Itterate through the songs
- foreach ($this->songs as $song_id) {
-
- $song = new Song($song_id);
- $song->format();
+ foreach ($this->media as $element) {
+ $type = array_shift($element);
+ $media = new $type(array_shift($element));
+
+ switch ($type) {
+ case 'song':
+ $xml['track']['title'] = $media->title;
+ $xml['track']['creator'] = $media->f_artist_full;
+ $xml['track']['info'] = Config::get('web_path') . "/albums.php?action=show&album=" . $media->album;
+ $xml['track']['image'] = Config::get('web_path') . "/image.php?id=" . $media->album . "&thumb=3&sid=" . session_id();
+ $xml['track']['album'] = $media->f_album_full;
+ $length = $media->time;
+ break;
+ default:
+
+ break;
+ } // type
$xml = array();
- $xml['track']['location'] = $song->get_url(self::$session) . $flash_hack;
+ $xml['track']['location'] = call_user_func($type,'play_url',$media->id) . $flash_hack;
$xml['track']['identifier'] = $xml['track']['location'];
- $xml['track']['title'] = $song->title;
- $xml['track']['creator'] = $song->f_artist_full;
- $xml['track']['info'] = Config::get('web_path') . "/albums.php?action=show&album=" . $song->album;
- $xml['track']['image'] = Config::get('web_path') . "/image.php?id=" . $song->album . "&thumb=3&sid=" . session_id();
- $xml['track']['album'] = $song->f_album_full;
- $xml['track']['duration'] = $song->time * 1000;
- $result .= xml_from_array($xml,1,'xspf');
+ $xml['track']['duration'] = $length * 1000;
- } // end foreach
+ $result .= xmlData::keyed_array($xml,1);
- foreach ($this->urls as $url) {
- $xml = array();
- $xml['track']['location'] = $url . $flash_hack;
- $xml['track']['identifier'] = $url . $flash_hack;
- $xml['track']['title'] = _('Ampache');
- $xml['track']['creator'] = _('Random');
- $xml['track']['duration'] = 9000;
- $result .= xml_from_array($xml,1,'xspf');
- }
+ } // end foreach
+
+ xmlData::set_type('xspf');
header("Cache-control: public");
header("Content-Disposition: filename=ampache-playlist.xspf");
header("Content-Type: application/xspf+xml; charset=utf-8");
- echo xml_get_header('xspf');
+ echo xmlData::header();
echo $result;
- echo xml_get_footer('xspf');
+ echo xmlData::footer();
} // create_xspf
@@ -466,18 +508,21 @@ class Stream {
// First figure out what their current one is and create the object
$localplay = new Localplay(Config::get('localplay_controller'));
$localplay->connect();
- //HACK!!!
- // Yea.. you know the baby jesus... he's crying right meow
- foreach ($this->songs as $song_id) {
- if ($song_id > 0) {
- $song = new Song($song_id);
- $localplay->add($song);
- }
- else {
- $url = array_shift($this->urls);
- $localplay->add($url);
- }
- }
+ foreach ($this->media as $element) {
+ $type = array_shift($element);
+ switch ($type) {
+ case 'video':
+ // Add check for video support
+ case 'song':
+ case 'radio':
+ $media = new $type(array_shift($element));
+ break;
+ default:
+ $media = array_shift($element);
+ break;
+ } // switch on types
+ $localplay->add($media);
+ } // foreach object
$localplay->play();
@@ -492,7 +537,7 @@ class Stream {
$democratic = Democratic::get_current_playlist();
$democratic->set_parent();
- $democratic->vote($this->songs);
+ $democratic->vote($this->media);
} // create_democratic
@@ -504,7 +549,7 @@ class Stream {
private function create_download() {
// Build up our object
- $song_id = $this->songs['0'];
+ $song_id = $this->media['0'];
$song = new Song($song_id);
$url = $song->get_url();
@@ -526,7 +571,7 @@ class Stream {
header("Cache-control: public");
header("Content-Disposition: filename=playlist.ram");
header("Content-Type: audio/x-pn-realaudio ram;");
- foreach ($this->songs as $song_id) {
+ foreach ($this->media as $song_id) {
$song = new Song($song_id);
echo $song->get_url();
} // foreach songs
@@ -755,7 +800,7 @@ class Stream {
* get_base_url
* This returns the base requirements for a stream URL this does not include anything after the index.php?sid=????
*/
- public static function get_base_url($session_id='',$force_http='') {
+ public static function get_base_url() {
if (Config::get('require_session')) {
$session_string = 'sid=' . Stream::get_session() . '&';
@@ -763,7 +808,7 @@ class Stream {
$web_path = Config::get('web_path');
- if (Config::get('force_http_play') OR !empty($force_http)) {
+ if (Config::get('force_http_play') OR !empty(self::$force_http)) {
$port = Config::get('http_port');
if (preg_match("/:\d+/",$web_path)) {
$web_path = str_replace("https://", "http://",$web_path);
diff --git a/lib/class/tmpplaylist.class.php b/lib/class/tmpplaylist.class.php
index a0654a2a..6abdc36b 100644
--- a/lib/class/tmpplaylist.class.php
+++ b/lib/class/tmpplaylist.class.php
@@ -140,7 +140,7 @@ class tmpPlaylist {
while ($results = Dba::fetch_assoc($db_results)) {
$key = $results['id'];
- $items[$key] = array($results['object_id'],$results['object_type']);
+ $items[$key] = array($results['object_type'],$results['object_id']);
}
return $items;
diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php
index f4087edf..894ab541 100644
--- a/lib/class/xmldata.class.php
+++ b/lib/class/xmldata.class.php
@@ -103,6 +103,26 @@ class xmlData {
} // single_string
/**
+ * header
+ * This returns the header
+ */
+ public static function header() {
+
+ return self::_header();
+
+ } // header
+
+ /**
+ * footer
+ * This returns the footer
+ */
+ public static function footer() {
+
+ return self::_footer();
+
+ } // header
+
+ /**
* keyed_array
* This will build an xml document from a key'd array,
*/
@@ -261,6 +281,7 @@ class xmlData {
}
Rating::build_cache('song',$songs);
+ Stream::set_session($_REQUEST['auth']);
// Foreach the ids!
foreach ($songs as $song_id) {
@@ -279,7 +300,7 @@ class xmlData {
"\t<track>$song->track</track>\n" .
"\t<time>$song->time</time>\n" .
"\t<mime>$song->mime</mime>\n" .
- "\t<url><![CDATA[" . $song->get_url($_REQUEST['auth']) . "]]></url>\n" .
+ "\t<url><![CDATA[" . Song::play_url($song->id) . "]]></url>\n" .
"\t<size>$song->size</size>\n" .
"\t<art><![CDATA[" . $art_url . "]]></art>\n" .
"\t<preciserating>" . $rating->preciserating . "</preciserating>\n" .
@@ -323,10 +344,29 @@ class xmlData {
switch (self::$type) {
case 'xspf':
-
+ $header = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" .
+ "<!-- XML Generated by Ampache v." . Config::get('version') . " -->";
+ "<playlist version = \"1\" xmlns=\"http://xspf.org/ns/0/\">\n ".
+ "<title>Ampache XSPF Playlist</title>\n" .
+ "<creator>" . Config::get('site_title') . "</creator>\n" .
+ "<annotation>" . Config::get('site_title') . "</annotation>\n" .
+ "<info>". Config::get('web_path') ."</info>\n" .
+ "<trackList>\n\n\n\n";
break;
case 'itunes':
-
+ $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" .
+ "<!-- XML Generated by Ampache v." . Config::get('version') . " -->";
+ "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"\n" .
+ "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" .
+ "<plist version=\"1.0\">\n" .
+ "<dict>\n" .
+ " <key>Major Version</key><integer>1</integer>\n" .
+ " <key>Minor Version</key><integer>1</integer>\n" .
+ " <key>Application Version</key><string>7.0.2</string>\n" .
+ " <key>Features</key><integer>1</integer>\n" .
+ " <key>Show Content Ratings</key><true/>\n" .
+ " <key>Tracks</key>\n" .
+ " <dict>\n";
break;
case 'rss':
$header = "<?xml version=\"1.0\" encoding=\"" . Config::get('site_charset') . "\" ?>\n " .
@@ -349,6 +389,12 @@ class xmlData {
private static function _footer() {
switch (self::$type) {
+ case 'itunes':
+ $footer = "\t\t</dict>\t\n</dict>\n</plist>\n";
+ break;
+ case 'xspf':
+ $footer = "\t</trackList>\n</playlist>\n";
+ break;
case 'rss':
$footer = "\n</channel>\n</rss>\n";
break;
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 1c2c480e..3af00f8d 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -865,12 +865,13 @@ function xml_get_header($type){
break;
case 'xspf':
$header = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" .
- "<playlist version = \"1\" xmlns=\"http://xspf.org/ns/0/\">\n ".
- "<title>Ampache XSPF Playlist</title>\n" .
- "<creator>" . Config::get('site_title') . "</creator>\n" .
- "<annotation>" . Config::get('site_title') . "</annotation>\n" .
- "<info>". Config::get('web_path') ."</info>\n" .
- "<trackList>\n\n\n\n";
+ "<!-- XML Generated by Ampache v." . Config::get('version') . " -->";
+ "<playlist version = \"1\" xmlns=\"http://xspf.org/ns/0/\">\n ".
+ "<title>Ampache XSPF Playlist</title>\n" .
+ "<creator>" . Config::get('site_title') . "</creator>\n" .
+ "<annotation>" . Config::get('site_title') . "</annotation>\n" .
+ "<info>". Config::get('web_path') ."</info>\n" .
+ "<trackList>\n\n\n\n";
return $header;
break;
default: