summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/localplay/mpd.controller.php6
-rw-r--r--modules/mpd/mpd.class.php104
2 files changed, 65 insertions, 45 deletions
diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php
index b81b6a95..1d850b48 100644
--- a/modules/localplay/mpd.controller.php
+++ b/modules/localplay/mpd.controller.php
@@ -109,8 +109,10 @@ class AmpacheMpd {
* and then add them to MPD
*/
function add_songs($songs) {
- /* Clear the playlist first */
- $this->clean_playlist();
+
+ if (is_null($this->_mpd->ClearPLIfStopped())) {
+ debug_event('mpd_add', 'Error: Unable to clear the MPD playlist ' . $this->_mpd->errStr,'1');
+ }
foreach ($songs as $song_id) {
$song = new Song($song_id);
diff --git a/modules/mpd/mpd.class.php b/modules/mpd/mpd.class.php
index 1191f39a..ca853936 100644
--- a/modules/mpd/mpd.class.php
+++ b/modules/mpd/mpd.class.php
@@ -1,25 +1,27 @@
-<?php
-/*
- * mpd.class.php - PHP Object Interface to the MPD Music Player Daemon
- * Version 1.2, Released 05/05/2004
- * Copyright (C) 2003-2004 Benjamin Carlisle (bcarlisle@24oz.com)
- * http://mpd.24oz.com/ | http://www.musicpd.org/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
+<?php
+/*
+ * mpd.class.php - PHP Object Interface to the MPD Music Player Daemon
+ * Version 1.2, Released 05/05/2004
+ * Copyright (C) 2003-2004 Benjamin Carlisle (bcarlisle@24oz.com)
+ * http://mpd.24oz.com/ | http://www.musicpd.org/
+ * Addition of Connection Timeout - Karl Vollmer (www.ampache.org)
+ * Addition of ClearPLIfStopped Function - Henrik (henrikDOTprobellATgmailDOTcom)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
// Create common command definitions for MPD to use
define("MPD_CMD_STATUS", "status");
define("MPD_CMD_STATISTICS", "stats");
@@ -972,24 +974,40 @@ class mpd {
$playlist = $this->_parseFileListResponse($resp);
if ( $this->debugging ) echo "mpd->GetPlaylist() / return ".print_r($playlist)."\n";
return $playlist;
- }
-
- /* ----------------- Command compatibility tables --------------------- */
- var $COMPATIBILITY_MIN_TBL = array(
- MPD_CMD_SEEK => "0.9.1" ,
- MPD_CMD_PLMOVE => "0.9.1" ,
- MPD_CMD_RANDOM => "0.9.1" ,
- MPD_CMD_PLSWAPTRACK => "0.9.1" ,
- MPD_CMD_PLMOVETRACK => "0.9.1" ,
- MPD_CMD_PASSWORD => "0.10.0" ,
- MPD_CMD_SETVOL => "0.10.0"
- );
-
- var $COMPATIBILITY_MAX_TBL = array(
- MPD_CMD_VOLUME => "0.10.0"
- );
-
-} // ---------------------------- end of class ------------------------------
-
-
-?>
+ }
+
+ /* ClearPLIfStopped()
+ *
+ * This function clears the mpd playlist ONLY IF the mpd state is MPD_STATE_STOPPED
+ */
+ function ClearPLIfStopped() {
+
+ if ( $this->debugging ) echo "mpd->ClearPLIfStopped()\n";
+ $this->RefreshInfo();
+ if ($resp = ($this->state == MPD_STATE_STOPPED)) {
+ $this->PLClear();
+ }
+ if ( $this->debugging ) echo "mpd->ClearPLIfStopped() / return\n";
+ return $resp;
+
+ } // ClearPLIfStopped
+
+ /* ----------------- Command compatibility tables --------------------- */
+ var $COMPATIBILITY_MIN_TBL = array(
+ MPD_CMD_SEEK => "0.9.1" ,
+ MPD_CMD_PLMOVE => "0.9.1" ,
+ MPD_CMD_RANDOM => "0.9.1" ,
+ MPD_CMD_PLSWAPTRACK => "0.9.1" ,
+ MPD_CMD_PLMOVETRACK => "0.9.1" ,
+ MPD_CMD_PASSWORD => "0.10.0" ,
+ MPD_CMD_SETVOL => "0.10.0"
+ );
+
+ var $COMPATIBILITY_MAX_TBL = array(
+ MPD_CMD_VOLUME => "0.10.0"
+ );
+
+} // ---------------------------- end of class ------------------------------
+
+
+?>