diff options
-rwxr-xr-x | docs/CHANGELOG | 2 | ||||
-rw-r--r-- | lib/class/playlist.class.php | 29 | ||||
-rw-r--r-- | lib/general.js | 2 | ||||
-rw-r--r-- | song.php | 15 |
4 files changed, 31 insertions, 17 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 4cd69627..46b5324a 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,8 @@ -------------------------------------------------------------------------- v.3.3.2-Beta2 + - Fixed play selected on playlists, it no longer always plays + everything. - Fixed redirection after applying a rating to an album - Fixed a few typos in the xmlrpc code and playlists and fixed the weird skipping when seeking using some players (Thx Sven) diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php index c89ac420..51399b41 100644 --- a/lib/class/playlist.class.php +++ b/lib/class/playlist.class.php @@ -111,13 +111,36 @@ class Playlist { * This returns an array of song_ids accounting for any dyn_song entries this playlist * may have. This is what should be called when trying to generate a m3u or other playlist */ - function get_songs() { + function get_songs($array=array()) { + + $results = array(); + + /* If we've passed in some songs */ + if (count($array)) { + + foreach ($array as $data) { + + $sql = "SELECT song,dyn_song FROM playlist_data WHERE id='" . sql_escape($data) . "'"; + $db_results = mysql_query($sql, dbh()); + + $r = mysql_fetch_assoc($db_results); + if ($r['dyn_song']) { + $array = $this->get_dyn_songs($r['dyn_song']); + $results = array_merge($array,$results); + } + else { + $results[] = $r['song']; + } + + } // end foreach songs + + return $results; + + } // end if we were passed some data $sql = "SELECT * FROM playlist_data WHERE playlist='" . sql_escape($this->id) . "'"; $db_results = mysql_query($sql, dbh()); - $results = array(); - while ($r = mysql_fetch_assoc($db_results)) { if ($r['dyn_song']) { $array = $this->get_dyn_songs($r['dyn_song']); diff --git a/lib/general.js b/lib/general.js index 879da45a..d196e8f0 100644 --- a/lib/general.js +++ b/lib/general.js @@ -65,7 +65,7 @@ function handleStateChange() { } // end if break; case 'now_playing' : - if (player == 'mpd') { + if (player == 'mpd' && (player_state == 'play')) { mpd_song_length = el.getElementsByTagName ('songlength')[0].firstChild.data; mpd_songid = Math.round(el.getElementsByTagName ('songid')[0].firstChild.data); document.getElementById ('mpd_npinfo').firstChild.data = @@ -43,7 +43,6 @@ $song_ids = array(); $web_path = conf('web_path'); $action = scrub_in($_REQUEST['action']); - switch ($action) { case 'play_selected': $type = scrub_in($_REQUEST['type']); @@ -52,7 +51,7 @@ switch ($action) { } elseif ($_REQUEST['playlist_id']) { $playlist = new Playlist($_REQUEST['playlist_id']); - $song_ids = $playlist->get_songs(); + $song_ids = $playlist->get_songs($_REQUEST['song']); } else { $song_ids = $_POST['song']; @@ -71,7 +70,7 @@ switch ($action) { break; case 'playlist': $playlist = new Playlist($_REQUEST['playlist_id']); - $song_ids = $playlist->get_songs(); + $song_ids = $playlist->get_songs($_REQUEST['song']); $_REQUEST['action'] = 'm3u'; case 'playlist_random': $playlist = new Playlist($_REQUEST['playlist_id']); @@ -85,16 +84,6 @@ switch ($action) { if ($_REQUEST['album']) { $song_ids = get_song_ids_from_album( $_REQUEST['album'] ); } -elseif ( $_REQUEST['playlist_id'] AND $action != 'play_selected') { - $playlist = new Playlist($_REQUEST['playlist_id']); - if ($_REQUEST['action'] == "random") { - $song_ids = $playlist->get_random_songs(); - $_REQUEST['action'] = "m3u"; - } - else { - $song_ids = $playlist->get_songs(); - } -} elseif ( $_REQUEST['artist'] ) { $artist = new Artist($_REQUEST['artist']); $song_ids = $artist->get_song_ids(); |