summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-02 15:16:07 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-02 15:16:07 +0100
commita63eff31169b700c1e3384f745eae5c26618ed45 (patch)
treec662e863e8261efb84d89ba9ac07341b11742246
parent044a715c61f1b78cb569fd7711d794296b61b994 (diff)
few tweaks to playqueue
-rw-r--r--main.c1
-rw-r--r--playlist.c9
-rw-r--r--playlist.h3
-rw-r--r--streamer.c13
4 files changed, 25 insertions, 1 deletions
diff --git a/main.c b/main.c
index fade5762..b55b13a3 100644
--- a/main.c
+++ b/main.c
@@ -320,6 +320,7 @@ player_thread (uintptr_t ctx) {
break;
case M_PLAYSONGNUM:
p_stop ();
+ pl_playqueue_clear ();
streamer_set_nextsong (p1, 1);
break;
case M_STOPSONG:
diff --git a/playlist.c b/playlist.c
index d75fd39c..5c6a2890 100644
--- a/playlist.c
+++ b/playlist.c
@@ -2038,6 +2038,7 @@ pl_playqueue_remove (playItem_t *it) {
}
}
}
+
int
pl_playqueue_test (playItem_t *it) {
for (int i = 0; i < playqueue_count; i++) {
@@ -2047,3 +2048,11 @@ pl_playqueue_test (playItem_t *it) {
}
return -1;
}
+
+playItem_t *
+pl_playqueue_getnext (void) {
+ if (playqueue_count > 0) {
+ return playqueue[0];
+ }
+ return NULL;
+}
diff --git a/playlist.h b/playlist.h
index 5cf62f21..731f4c32 100644
--- a/playlist.h
+++ b/playlist.h
@@ -227,4 +227,7 @@ pl_playqueue_remove (playItem_t *it);
int
pl_playqueue_test (playItem_t *it);
+playItem_t *
+pl_playqueue_getnext (void);
+
#endif // __PLAYLIST_H
diff --git a/streamer.c b/streamer.c
index 88e02386..52f41e11 100644
--- a/streamer.c
+++ b/streamer.c
@@ -943,7 +943,18 @@ streamer_play_current_track (void) {
else if (playlist_current_row[PL_MAIN] != -1) {
// play currently selected track
p_stop ();
- streamer_set_nextsong (playlist_current_row[PL_MAIN], 1);
+ // get next song in queue
+ int idx = -1;
+ playItem_t *next = pl_playqueue_getnext ();
+ if (next) {
+ idx = pl_get_idx_of (next);
+ pl_playqueue_pop ();
+ }
+ else {
+ idx = playlist_current_row[PL_MAIN];
+ }
+
+ streamer_set_nextsong (idx, 1);
}
else {
// restart currently playing track