diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-08-13 04:30:26 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-08-13 04:30:26 +0000 |
commit | e7fea90327419214531371543662056c1398470d (patch) | |
tree | 8b7642b5cac62994ff55f80e733dedbff22105bf /lib | |
parent | 3836a33d1c210a806c13f9bb172724394fb3fd80 (diff) | |
download | ampache-e7fea90327419214531371543662056c1398470d.tar.gz ampache-e7fea90327419214531371543662056c1398470d.tar.bz2 ampache-e7fea90327419214531371543662056c1398470d.zip |
new mpd mojo from rosensama and rperkins
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/playlist.class.php | 12 | ||||
-rw-r--r-- | lib/mpd.php | 14 |
2 files changed, 21 insertions, 5 deletions
diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php index b17eadc6..7fa55492 100644 --- a/lib/class/playlist.class.php +++ b/lib/class/playlist.class.php @@ -186,18 +186,26 @@ class Playlist { /*! @function add_songs @discussion Reads an array of song_ids to add to the playlist + @param $song_ids the array of song_ids + @param $is_ordered boolean, if true insert in order submitted, not by track number */ - function add_songs($song_ids) { + function add_songs($song_ids, $is_ordered = false) { $dbh = dbh(); if ($this->id && isset($song_ids) && is_array($song_ids)) { + $count = 0; foreach ($song_ids as $song_id) { + if( $is_ordered ) { + $track_num = $count++; + } else { + $track_num = $song->track; + } $song = new Song($song_id); if (isset($song->id)) { $sql = "INSERT INTO playlist_data" . " (playlist, song, track)" . - " VALUES ('$this->id', '$song->id', '$song->track')"; + " VALUES ('$this->id', '$song->id', '$track_num')"; $db_results = mysql_query($sql, $dbh); } } diff --git a/lib/mpd.php b/lib/mpd.php index 5eacddad..efbbda6e 100644 --- a/lib/mpd.php +++ b/lib/mpd.php @@ -90,10 +90,11 @@ function show_mpd_pl() { * Redriect mojo * @package Local Play * @catagory MPD + * @param $page is the URL after conf('web_path') . '/' */ -function mpd_redirect() { +function mpd_redirect( $page = 'mpd.php' ) { if (conf('localplay_menu')) { - header ("Location: " . conf('web_path') . "/mpd.php"); + header ("Location: " . conf('web_path') . '/' . $page); } else { header ("Location: " . conf('web_path')); @@ -119,8 +120,15 @@ function init_mpd() { $myMpd = new mpd(conf('mpd_host'),conf('mpd_port')); } + if (!$myMpd->connected AND is_object($myMpd)) { + // Attempt to reconnect + $myMpd->Connect(); + } + if (!$myMpd->connected) { - if (conf('debug')) { log_event ($_SESSION['userdata']['username'],' connection_failed ',"Error: unable to connect to MPD, ".$myMpd->errStr); } + if (conf('debug')) { + log_event ($_SESSION['userdata']['username'],' connection_failed ',"Error: unable to connect to ". conf('mpd_host') . " on port " . conf('mpd_port') . " ".$myMpd->errStr); + } return false; } |