summaryrefslogtreecommitdiff
path: root/playlist.c
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 /playlist.c
parent0d481f30b211f9c596dc9f304cd651936e76da07 (diff)
added random playback mode
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c12
1 files changed, 12 insertions, 0 deletions
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 ();