summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--stream.php71
-rw-r--r--templates/rightbar.inc.php11
-rw-r--r--templates/show_song.inc.php2
-rw-r--r--templates/show_song_row.inc.php2
15 files changed, 286 insertions, 233 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:
diff --git a/stream.php b/stream.php
index c33da1ce..ce7437de 100644
--- a/stream.php
+++ b/stream.php
@@ -26,7 +26,7 @@ if (Config::get('demo_mode') || !Access::check('interface','25')) {
exit;
}
-$song_ids = array();
+$media_ids = array();
$web_path = Config::get('web_path');
/**
@@ -35,30 +35,7 @@ $web_path = Config::get('web_path');
switch ($_REQUEST['action']) {
case 'basket':
// Pull in our items (multiple types)
- $objects = $GLOBALS['user']->playlist->get_items();
-
- //Recurse through the objects
- foreach ($objects as $object_data) {
- // Switch on the type of object we've got in here
- switch ($object_data['1']) {
- case 'radio':
- $radio = new Radio($object_data['0']);
- $urls[] = $radio->url;
- break;
- case 'song':
- $song_ids[] = $object_data['0'];
- break;
- case 'video':
- $video_url = Video::play_url($object_data['0']);
- if ($video_url) { $urls[] = $video_url; }
- break;
- default:
- $random_url = Random::play_url($object_data['1']);
- // If there's something to actually add
- if ($random_url) { $urls[] = $random_url; }
- break;
- } // end switch on type
- } // end foreach
+ $media_ids = $GLOBALS['user']->playlist->get_items();
// Check to see if 'clear' was passed if it was then we need to reset the basket
if ( ($_REQUEST['playlist_method'] == 'clear' || Config::get('playlist_method') == 'clear') AND Config::get('play_type') != 'xspf_player') {
@@ -69,67 +46,67 @@ switch ($_REQUEST['action']) {
/* This is run if we need to gather info based on a tmp playlist */
case 'tmp_playlist':
$tmp_playlist = new tmpPlaylist($_REQUEST['tmpplaylist_id']);
- $song_ids = $tmp_playlist->get_items();
+ $media_ids = $tmp_playlist->get_items();
break;
case 'play_favorite':
$data = $GLOBALS['user']->get_favorites($_REQUEST['type']);
- $song_ids = array();
+ $media_ids = array();
switch ($_REQUEST['type']) {
case 'artist':
case 'album':
foreach ($data as $value) {
$songs = $value->get_songs();
- $song_ids = array_merge($song_ids,$songs);
+ $media_ids = array_merge($media_ids,$songs);
}
break;
case 'song':
foreach ($data as $value) {
- $song_ids[] = $value->id;
+ $media_ids[] = $value->id;
}
break;
} // end switch on type
break;
case 'single_song':
- $song_ids[] = scrub_in($_REQUEST['song_id']);
+ $media_ids[] = scrub_in($_REQUEST['song_id']);
break;
case 'your_popular_songs':
- $song_ids = get_popular_songs($_REQUEST['limit'], 'your', $GLOBALS['user']->id);
+ $media_ids = get_popular_songs($_REQUEST['limit'], 'your', $GLOBALS['user']->id);
break;
case 'popular_songs':
- $song_ids = get_popular_songs($_REQUEST['limit'], 'global');
+ $media_ids = get_popular_songs($_REQUEST['limit'], 'global');
break;
case 'genre':
$genre = new Genre($_REQUEST['genre']);
- $song_ids = $genre->get_songs();
+ $media_ids = $genre->get_songs();
break;
case 'artist':
$artist = new Artist($_REQUEST['artist_id']);
- $song_ids = $artist->get_songs();
+ $media_ids = $artist->get_songs();
break;
case 'artist_random':
$artist = new Artist($_REQUEST['artist_id']);
$artist->get_count();
- $song_ids = $artist->get_random_songs();
+ $media_ids = $artist->get_random_songs();
break;
case 'album_random':
$album = new Album($_REQUEST['album_id']);
- $song_ids = $album->get_random_songs();
+ $media_ids = $album->get_random_songs();
break;
case 'album':
$album = new Album($_REQUEST['album_id']);
- $song_ids = $album->get_songs();
+ $media_ids = $album->get_songs();
break;
case 'random_genre':
$genre = new Genre($_REQUEST['genre']);
- $song_ids = $genre->get_random_songs();
+ $media_ids = $genre->get_random_songs();
break;
case 'playlist':
$playlist = new Playlist($_REQUEST['playlist_id']);
- $song_ids = $playlist->get_songs($_REQUEST['song']);
+ $media_ids = $playlist->get_songs($_REQUEST['song']);
break;
case 'playlist_random':
$playlist = new Playlist($_REQUEST['playlist_id']);
- $song_ids = $playlist->get_random_songs();
+ $media_ids = $playlist->get_random_songs();
break;
case 'random':
if($_REQUEST['genre'][0] != '-1') {
@@ -140,14 +117,14 @@ switch ($_REQUEST['action']) {
}
/* Setup the options array */
$options = array('limit' => $_REQUEST['random'], 'random_type' => $_REQUEST['random_type'],'size_limit'=>$_REQUEST['size_limit']);
- $song_ids = get_random_songs($options, $matchlist);
+ $media_ids = get_random_songs($options, $matchlist);
break;
case 'democratic':
$democratic = new Democratic($_REQUEST['democratic_id']);
- $urls[] = $democratic->get_url();
+ $urls[] = $democratic->play_url();
break;
case 'download':
- $song_ids[] = $_REQUEST['song_id'];
+ $media_ids[] = $_REQUEST['song_id'];
default:
break;
} // end action switch
@@ -164,7 +141,7 @@ switch ($_REQUEST['method']) {
// Format the zip file
$name = "AmpacheZip-" . date("m-d-Y",time());
- $song_files = get_song_files($song_ids);
+ $song_files = get_song_files($media_ids);
set_memory_limit($song_files[1]+32);
send_zip($name,$song_files[0]);
break;
@@ -191,11 +168,9 @@ switch ($_REQUEST['method']) {
}
/* Start the Stream */
- $stream = new Stream($stream_type,$song_ids);
+ $stream = new Stream($stream_type,$media_ids);
if (is_array($urls)) {
- foreach ($urls as $url) {
- $stream->manual_url_add($url);
- }
+ $stream->manual_url_add($urls);
}
$stream->start();
break;
diff --git a/templates/rightbar.inc.php b/templates/rightbar.inc.php
index 990d4f20..01a6aa10 100644
--- a/templates/rightbar.inc.php
+++ b/templates/rightbar.inc.php
@@ -88,17 +88,14 @@
$objects = array_slice($objects,0,100);
}
- $normal_array = array('radio','song','video');
+ $normal_array = array('radio','song','video','random');
foreach ($objects as $uid=>$object_data) {
- if (in_array($object_data['1'],$normal_array)) {
- $object = new $object_data['1']($object_data['0']);
+ $type = array_shift($object_data);
+ if (in_array($type,$normal_array)) {
+ $object = new $type(array_shift($object_data));
$object->format();
}
- else {
- $object = new Random();
- $object->f_link = Random::get_type_name($object_data['1']);
- }
?>
<li class="<?php echo flip_class(); ?>" >
<?php echo $object->f_link; ?>
diff --git a/templates/show_song.inc.php b/templates/show_song.inc.php
index 45f8c90c..000e1581 100644
--- a/templates/show_song.inc.php
+++ b/templates/show_song.inc.php
@@ -28,7 +28,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
<dd class"<?php echo $rowparity; ?>">
<?php echo Ajax::button('?action=basket&type=song&id=' . $song->id,'add',_('Add'),'add_song_' . $song->id); ?>
<?php if (Access::check_function('download')) { ?>
- <a href="<?php echo $song->get_url(); ?>"><?php echo get_user_icon('link'); ?></a>
+ <a href="<?php echo Song::play_url($song->id); ?>"><?php echo get_user_icon('link'); ?></a>
<a href="<?php echo Config::get('web_path'); ?>/stream.php?action=download&amp;song_id=<?php echo $song->id; ?>"><?php echo get_user_icon('download'); ?></a>
<?php } ?>
<?php if (Access::check('interface','75')) { ?>
diff --git a/templates/show_song_row.inc.php b/templates/show_song_row.inc.php
index 926940c0..55b99ff3 100644
--- a/templates/show_song_row.inc.php
+++ b/templates/show_song_row.inc.php
@@ -22,7 +22,7 @@
<td class="cel_add">
<?php echo Ajax::button('?action=basket&type=song&id=' . $song->id,'add',_('Add'),'add_' . $song->id); ?>
</td>
-<td class="cel_song"><a href="<?php echo $song->get_url(); ?>"><?php echo $song->f_title; ?></a></td>
+<td class="cel_song"><a href="<?php echo Song::play_url($song->id); ?>"><?php echo $song->f_title; ?></a></td>
<td class="cel_artist"><?php echo $song->f_artist_link; ?></td>
<td class="cel_album"><?php echo $song->f_album_link; ?></td>
<td class="cel_tags"><?php echo $song->f_tags; ?></td>