diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-09-20 07:39:45 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-09-20 07:39:45 +0000 |
commit | 1dfdf2afab8da95da8c814e3838b3393d88ae53c (patch) | |
tree | f97be5925ed2dbef028d0902861771ea0a3ec473 /lib | |
parent | 649c44446a2368ac004ffa5778704f7213cf54ad (diff) | |
download | ampache-1dfdf2afab8da95da8c814e3838b3393d88ae53c.tar.gz ampache-1dfdf2afab8da95da8c814e3838b3393d88ae53c.tar.bz2 ampache-1dfdf2afab8da95da8c814e3838b3393d88ae53c.zip |
made localplay technically work, lots of work to still do
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/localplay.abstract.php | 17 | ||||
-rw-r--r-- | lib/class/localplay.class.php | 24 | ||||
-rw-r--r-- | lib/class/radio.class.php | 10 | ||||
-rw-r--r-- | lib/class/song.class.php | 4 | ||||
-rw-r--r-- | lib/class/stream.class.php | 45 |
5 files changed, 52 insertions, 48 deletions
diff --git a/lib/class/localplay.abstract.php b/lib/class/localplay.abstract.php index d8e21387..d66750a7 100644 --- a/lib/class/localplay.abstract.php +++ b/lib/class/localplay.abstract.php @@ -50,8 +50,21 @@ abstract class localplay_controller { * get_url * This returns the URL for the passed object */ - private function get_url($object) { + public function get_url($object) { + // This can get a little complicated + switch ($object_type) { + case 'random': + + break; + case 'radio': + case 'song': + default: + $url = $object->get_url(Stream::$session); + break; + } // end switch on objecttype + + return $url; } // get_url @@ -60,7 +73,7 @@ abstract class localplay_controller { * This returns the Filename for the passed object, not * always possible */ - private function get_file($object) { + public function get_file($object) { } // get_file diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index 2f77cfd9..c5b16fd3 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -224,14 +224,7 @@ class Localplay { */ public function connect() { - $function = $this->_function_map['connect']; - - /* This is very bad, that means they don't even - * have a connection function defined - */ - if (!$function) { return false; } - - if (!$this->_player->$function()) { + if (!$this->_player->connect()) { debug_event('localplay','Error Unable to connect, check ' . $this->type . ' controller','1'); return false; } @@ -247,9 +240,7 @@ class Localplay { */ public function play() { - $function = $this->_function_map['play']; - - if (!$this->_player->$function()) { + if (!$this->_player->play()) { debug_event('localplay','Error Unable to start playback, check ' . $this->type . ' controller','1'); return false; } @@ -278,20 +269,15 @@ class Localplay { /** * add - * This function takes an array of song_ids and then passes the full URL + * This function takes a single object and then passes it to * to the player, this is a required function. */ - public function add($songs) { - - - /* Call the Function Specified in the Function Map */ - $function = $this->_function_map['add']; + public function add($object) { - if (!$this->_player->$function($songs)) { + if (!$this->_player->add($object)) { debug_event('localplay','Error Unable to add songs, check ' . $this->type . ' controller','1'); return false; } - return true; diff --git a/lib/class/radio.class.php b/lib/class/radio.class.php index 97bde2f6..45f57ade 100644 --- a/lib/class/radio.class.php +++ b/lib/class/radio.class.php @@ -96,6 +96,16 @@ class Radio { } // 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 diff --git a/lib/class/song.class.php b/lib/class/song.class.php index af03e921..98de5616 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -799,10 +799,6 @@ class Song { $type = $this->type; - if ($GLOBALS['user']->prefs['play_type'] == 'downsample') { - $ds_string = "&ds=" . $GLOBALS['user']->prefs['sample_rate']; - } - /* Account for retarded players */ if ($this->type == 'flac') { $type = 'ogg'; } diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 3e932997..7c07b8f3 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -36,6 +36,9 @@ class Stream { public $sess; public $user_id; + // Generate once an object is constructed + public static $session; + /** * Constructor for the stream class takes a type and an array * of song ids @@ -52,7 +55,7 @@ class Stream { } // Generate the session ID - $this->session = md5(uniqid(rand(), true));; + self::$session = md5(uniqid(rand(), true));; } // Constructor @@ -109,7 +112,7 @@ class Stream { $expire = time() + Config::get('stream_length'); $sql = "INSERT INTO `session_stream` (`id`,`expire`,`user`) " . - "VALUES('$this->session','$expire','$this->user_id')"; + "VALUES('" . self::$session . "','$expire','$this->user_id')"; $db_results = Dba::query($sql); if (!$db_results) { return false; } @@ -204,7 +207,7 @@ class Stream { if ($GLOBALS['user']->prefs['play_type'] == 'downsample') { $ds = $GLOBALS['user']->prefs['sample_rate']; } - echo $song->get_url($this->session); + echo $song->get_url(self::$session); } // end foreach /* Foreach the additional URLs */ @@ -241,7 +244,7 @@ class Stream { $song->format(); echo "#EXTINF:$song->time," . $song->f_artist_full . " - " . $song->title . "\n"; - echo $song->get_url($this->session) . "\n"; + echo $song->get_url(self::$session) . "\n"; } // end foreach /* Foreach URLS */ @@ -272,7 +275,7 @@ class Stream { $song = new Song($song_id); $song->format(); $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type; - $song_url = $song->get_url($this->session); + $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"; @@ -306,7 +309,7 @@ class Stream { foreach ($this->songs as $song_id) { $song = new Song($song_id); $song->format(); - $url = $song->get_url($this->session); + $url = $song->get_url(self::$session); $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type; echo "<ENTRY>\n"; @@ -350,7 +353,7 @@ class Stream { $song->format(); $xml = array(); - $xml['track']['location'] = $song->get_url($this->session) . $flash_hack; + $xml['track']['location'] = $song->get_url(self::$session) . $flash_hack; $xml['track']['identifier'] = $xml['track']['location']; $xml['track']['title'] = $song->title; $xml['track']['creator'] = $song->f_artist_full; @@ -428,23 +431,19 @@ class Stream { */ function create_localplay() { - if (!$localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller'])) { - debug_event('localplay','Player failed to init on song add','3'); - echo "Error: Localplay Init Failed check config"; - return false; - } + // First figure out what their current one is and create the object + $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); + $localplay->connect(); - if (!$localplay->connect()) { - debug_event('localplay','Localplay Player Connect failed','3'); - echo "Error: Localplay connect failed check config"; - return false; + //HACK!!! + // Yea.. you know the baby jesus... he's crying right meow + foreach ($this->songs as $song_id) { + $this->objects[] = new Song($song_id); } - $localplay->add($this->songs); - - /* Check for Support */ - if ($localplay->has_function('add_url')) { - $localplay->add_url($this->urls); + // Foreach the stuff we've got and add it + foreach ($this->objects as $object) { + $localplay->add($object,self::$session); } $localplay->play(); @@ -475,7 +474,7 @@ class Stream { // Build up our object $song_id = $this->songs['0']; $song = new Song($song_id); - $url = $song->get_url($this->session); + $url = $song->get_url(self::$session); // Append the fact we are downloading $url .= '&action=download'; @@ -497,7 +496,7 @@ class Stream { header("Content-Type: audio/x-pn-realaudio ram;"); foreach ($this->songs as $song_id) { $song = new Song($song_id); - echo $song->get_url($this->session); + echo $song->get_url(self::$session); } // foreach songs } // create_ram |