aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/playlist.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 474e11f4b..a91553140 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -499,7 +499,7 @@ static void queueNextSongInPlaylist(void)
if (playlist.length > 0) {
if (playlist.random)
randomizeOrder(0, playlist.length - 1);
- else
+ else if (ob_get_state() == OB_STATE_STOP)
playlist.current = -1;
}
} else if (dc.state == DC_STATE_STOP) {
@@ -866,10 +866,17 @@ enum playlist_result playPlaylist(int song, int stopOnError)
ob_trigger_action(OB_ACTION_PAUSE_UNSET);
return PLAYLIST_RESULT_SUCCESS;
}
- if (playlist.current >= 0 && playlist.current < playlist.length)
+
+ if (playlist_state == PLAYLIST_STATE_STOP &&
+ playlist.length > 0 &&
+ playlist.current == playlist.length - 1) {
+ i = 0;
+ } else if (playlist.current >= 0 &&
+ playlist.current < playlist.length) {
i = playlist.current;
- else
+ } else {
i = 0;
+ }
} else if (song < 0 || song >= playlist.length) {
return PLAYLIST_RESULT_BAD_RANGE;
}
@@ -1272,7 +1279,10 @@ enum playlist_result savePlaylist(const char *utf8file)
int getPlaylistCurrentSong(void)
{
- if (playlist.current >= 0 && playlist.current < playlist.length)
+ DEBUG("%s:%d current: %d\n", __func__, __LINE__, playlist.current);
+ if (ob_get_state() != OB_STATE_STOP &&
+ playlist.current >= 0 &&
+ playlist.current < playlist.length)
return playlist.order[playlist.current];
return -1;