diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-10-10 06:08:33 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-10-10 06:08:33 +0000 |
commit | 32349846fbd66e4ebc44e63d37fbcd8cff5a8a73 (patch) | |
tree | 6aa1acd81fcf798150ba2c702116aa5f4dcde63b /modules | |
parent | 8045c0121ca3e22af2945faa072c5de4b329d7d8 (diff) | |
download | ampache-32349846fbd66e4ebc44e63d37fbcd8cff5a8a73.tar.gz ampache-32349846fbd66e4ebc44e63d37fbcd8cff5a8a73.tar.bz2 ampache-32349846fbd66e4ebc44e63d37fbcd8cff5a8a73.zip |
fixed two MPD issues, can now disable localplay modules, added check for PHP5
Diffstat (limited to 'modules')
-rw-r--r-- | modules/localplay/mpd.controller.php | 14 | ||||
-rw-r--r-- | modules/mpd/mpd.class.php | 22 |
2 files changed, 20 insertions, 16 deletions
diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php index 4b3c953f..117c4c33 100644 --- a/modules/localplay/mpd.controller.php +++ b/modules/localplay/mpd.controller.php @@ -247,10 +247,13 @@ class AmpacheMpd extends localplay_controller { * functions to generate the URL it needs */ public function add($object) { - - if (is_null($this->_mpd->ClearPLIfStopped())) { - debug_event('mpd_add', 'Error: Unable to clear the MPD playlist ' . $this->_mpd->errStr,'1'); - } + + // If we haven't added anything then check to see if we should clear + if ($this->_add_count < '1') { + if (is_null($this->_mpd->ClearPLIfStopped())) { + debug_event('mpd_add', 'Error: Unable to clear the MPD playlist ' . $this->_mpd->errStr,'1'); + } + } // edn if no add count $url = $this->get_url($object); @@ -258,6 +261,9 @@ class AmpacheMpd extends localplay_controller { debug_event('mpd_add',"Error: Unable to add $url to MPD " . $this->_mpd->errStr,'1'); return false; } + else { + $this->_add_count++; + } return true; diff --git a/modules/mpd/mpd.class.php b/modules/mpd/mpd.class.php index 52ace825..529465fa 100644 --- a/modules/mpd/mpd.class.php +++ b/modules/mpd/mpd.class.php @@ -107,7 +107,6 @@ class mpd { // Misc Other Vars var $mpd_class_version = "1.2"; - var $debugging = FALSE; // Set to TRUE to turn extended debugging on. var $errStr = ""; // Used for maintaining information about the last error message var $command_queue; // The list of commands for bulk command sending @@ -118,7 +117,7 @@ class mpd { * * Builds the MPD object, connects to the server, and refreshes all local object properties. */ - function mpd($srv,$port,$pwd = NULL) { + public function __construct($srv,$port,$pwd = NULL) { $this->host = $srv; $this->port = $port; $this->password = $pwd; @@ -162,9 +161,8 @@ class mpd { * NOTE: This is called automatically upon object instantiation; you should not need to call this directly. */ public function Connect() { - if ( $this->debugging ) echo "mpd->Connect() / host: ".$this->host.", port: ".$this->port."\n"; + debug_event('MPD',"mpd->Connect() / host: ".$this->host.", port: ".$this->port,'5'); $this->mpd_sock = fsockopen($this->host,$this->port,$errNo,$errStr,6); - /* Vollmerize this bizatch, if we've got php4.3+ we should * have these functions and we need them */ @@ -182,7 +180,8 @@ class mpd { if (!$this->mpd_sock) { $this->errStr = "Socket Error: $errStr ($errNo)"; return NULL; - } else { + } + else { while(!feof($this->mpd_sock) && !$status['timed_out']) { $response = fgets($this->mpd_sock,1024); if (function_exists('socket_get_status')) { @@ -213,7 +212,7 @@ class mpd { * use (see MPD_CMD_* constant definitions above). */ function SendCommand($cmdStr,$arg1 = "",$arg2 = "") { - if ( $this->debugging ) echo "mpd->SendCommand() / cmd: ".$cmdStr.", args: ".$arg1." ".$arg2."\n"; + debug_event('MPD',"mpd->SendCommand() / cmd: ".$cmdStr.", args: ".$arg1." ".$arg2,'5'); if ( ! $this->connected ) { echo "mpd->SendCommand() / Error: Not connected\n"; } else { @@ -250,7 +249,7 @@ class mpd { // Build the response string $respStr .= $response; } - if ( $this->debugging ) echo "mpd->SendCommand() / response: '".$respStr."'\n"; + debug_event('MPD',"mpd->SendCommand() / response: '".$respStr,'5'); } return $respStr; } @@ -875,7 +874,6 @@ class mpd { if ( ($this->state == MPD_STATE_PLAYING) || ($this->state == MPD_STATE_PAUSED) ) { list ($this->current_track_position, $this->current_track_length ) = split(":",$status['time']); } else { -// $this->current_track_id = -1; $this->current_track_position = -1; $this->current_track_length = -1; } @@ -968,7 +966,7 @@ class mpd { /* GetPlaylist() * * Retrieves the playlist from the server and tosses it into a multidimensional array. - * + * * NOTE: This function really should not be used. Instead, use $this->playlist. The function * will most likely be deprecated in future releases. */ @@ -986,13 +984,13 @@ class mpd { */ function ClearPLIfStopped() { - if ( $this->debugging ) echo "mpd->ClearPLIfStopped()\n"; + debug_event('MPD',"Running: mpd->ClearPLIfStopped()",'5'); $this->RefreshInfo(); if ($resp = ($this->state == MPD_STATE_STOPPED)) { $this->PLClear(); + return true; } - if ( $this->debugging ) echo "mpd->ClearPLIfStopped() / return\n"; - return $resp; + return false; } // ClearPLIfStopped |