summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-08-08 14:19:12 +0200
committerGravatar waker <wakeroid@gmail.com>2009-08-08 14:19:12 +0200
commitebce9029317b1a9cc793728eefc8f844de184876 (patch)
tree950d5a31ef951dfbfcb2d4dae16e83ff384b127c
parent0d481f30b211f9c596dc9f304cd651936e76da07 (diff)
added random playback mode
-rw-r--r--gtkplaylist.c8
-rw-r--r--playlist.c12
-rw-r--r--playlist.h3
3 files changed, 16 insertions, 7 deletions
diff --git a/gtkplaylist.c b/gtkplaylist.c
index 01bcaca3..5026d32e 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -704,14 +704,8 @@ gtkps_prevsong (void) {
void
gtkps_randomsong (void) {
- if (!ps_getcount ()) {
- return;
- }
- GtkWidget *widget = lookup_widget (mainwin, "playlist");
- playItem_t *prev = playlist_current_ptr;
- int r = (float)rand ()/RAND_MAX * ps_getcount ();
p_stop ();
- streamer_set_nextsong (r, 1);
+ ps_randomsong ();
}
void
diff --git a/playlist.c b/playlist.c
index 8f25e9ab..88a3f724 100644
--- a/playlist.c
+++ b/playlist.c
@@ -654,6 +654,7 @@ ps_prevsong (void) {
return 0;
}
else if (ps_mode == 2) { // random
+ ps_randomsong ();
}
return -1;
}
@@ -704,10 +705,21 @@ ps_nextsong (void) {
return 0;
}
else if (ps_mode == 2) { // random
+ return ps_randomsong ();
}
return -1;
}
+int
+ps_randomsong (void) {
+ if (!ps_getcount ()) {
+ return -1;
+ }
+ int r = (float)rand ()/RAND_MAX * ps_getcount ();
+ streamer_set_nextsong (r, 1);
+ return 0;
+}
+
void
ps_start_current (void) {
codec_lock ();
diff --git a/playlist.h b/playlist.h
index 29d800c0..d59c87a1 100644
--- a/playlist.h
+++ b/playlist.h
@@ -80,6 +80,9 @@ ps_nextsong (void);
int
ps_prevsong (void);
+int
+ps_randomsong (void);
+
// starts current playlist item from position 0
// only if the item is still in playlist
void