diff options
-rw-r--r-- | modules/httpq/httpqplayer.class.php | 30 | ||||
-rw-r--r-- | modules/localplay/httpq.controller.php | 20 | ||||
-rw-r--r-- | modules/localplay/mpd.controller.php | 4 |
3 files changed, 29 insertions, 25 deletions
diff --git a/modules/httpq/httpqplayer.class.php b/modules/httpq/httpqplayer.class.php index 857a7de6..be2b264b 100644 --- a/modules/httpq/httpqplayer.class.php +++ b/modules/httpq/httpqplayer.class.php @@ -54,10 +54,11 @@ class HttpQPlayer { */
function add($name, $url) {
- $args["name"] = $name;
- $args["url"] = str_replace("&","%26",$url);
- $results = $this->sendCommand("playurl", $args);
-
+ $args['name'] = $name;
+ $args['url'] = str_replace("&","%26",$url);
+
+ $results = $this->sendCommand('playurl', $args);
+
if ($results == '0') { $results = null; }
return $results;
@@ -233,7 +234,7 @@ class HttpQPlayer { if ($results == '0') { $results = null; }
else {
/* Need to make this out of 100 */
- $results = ($results / 255) * 100;
+ $results = round((($results / 255) * 100),2);
}
return $results;
@@ -277,8 +278,8 @@ class HttpQPlayer { $pos = $this->sendCommand('getlistpos',array());
// Now get the filename
- $file = $this->sendCommand('getplaylistfile',array('index'=>$post));
-
+ $file = $this->sendCommand('getplaylistfile',array('index'=>$pos));
+
return $file;
} // get_now_playing
@@ -291,8 +292,8 @@ class HttpQPlayer { function get_tracks() {
// Pull a delimited list of all tracks
- $results = $this->sendCommand('getplaylistfile',array('delim'=>':'));
-
+ $results = $this->sendCommand('getplaylistfile',array('delim'=>'::'));
+
if ($results == '0') { $results = null; }
return $results;
@@ -331,11 +332,14 @@ class HttpQPlayer { }
fclose($fp);
- return $data;
+ // Explode the results by line break and take 4th line (results)
+ $data = explode("\n",$data);
+
+ $result = $data['4'];
+
+ return $result;
} // sendCommand
} // End HttpQPlayer Class
-
-
-?>
+?>
diff --git a/modules/localplay/httpq.controller.php b/modules/localplay/httpq.controller.php index 57b9d5af..a3f69665 100644 --- a/modules/localplay/httpq.controller.php +++ b/modules/localplay/httpq.controller.php @@ -115,7 +115,7 @@ class AmpacheHttpq { $song = new Song($song_id); $url = $song->get_url(0,1); if (is_null($this->_httpq->add($song->title,$url))) { - debug_event('httpq_add','Error: Unable to add $url to Httpq','1'); + debug_event('httpq_add',"Error: Unable to add $url to Httpq",'1'); } } // end foreach @@ -132,7 +132,7 @@ class AmpacheHttpq { foreach ($urls as $url) { if (is_null($this->_httpq->add('URL',$url))) { - debug_event('httpq_add','Error: Unable to add $url to Httpq ','1'); + debug_event('httpq_add',"Error: Unable to add $url to Httpq ",'1'); } } // end foreach @@ -323,28 +323,28 @@ class AmpacheHttpq { /* Get the Current Playlist */ $list = $this->_httpq->get_tracks(); - $songs = explode(":",$list); + $songs = explode("::",$list); - foreach ($songs as $key=>$song) { + foreach ($songs as $key=>$entry) { $data = array(); - + /* Required Elements */ $data['id'] = $key; - $data['raw'] = $entry['file']; + $data['raw'] = $entry; /* Parse out the song ID and then create the song object */ - preg_match("/song=(\d+)\&/",$entry['file'],$matches); + preg_match("/song=(\d+)\&/",$entry,$matches); /* Attempt to build the new song */ $song = new Song($matches['1']); /* If we don't know it, look up by filename */ if (!$song->title) { - $filename = sql_escape($entry['file']); + $filename = sql_escape($entry); $sql = "SELECT id FROM song WHERE file = '$filename'"; $db_results = mysql_query($sql, dbh()); - if ($results = mysql_fetch_assoc($db_results)) { - $song = new Song($results['id']); + if ($r = mysql_fetch_assoc($db_results)) { + $song = new Song($r['id']); } else { $song->title = _('Unknown'); diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php index 9875b72e..72ce56ab 100644 --- a/modules/localplay/mpd.controller.php +++ b/modules/localplay/mpd.controller.php @@ -347,8 +347,8 @@ class AmpacheMpd { $filename = sql_escape($entry['file']); $sql = "SELECT id FROM song WHERE file = '$filename'"; $db_results = mysql_query($sql, dbh()); - if ($results = mysql_fetch_assoc($db_results)) { - $song = new Song($results['id']); + if ($r = mysql_fetch_assoc($db_results)) { + $song = new Song($r['id']); } else { $song->title = _('Unknown'); |