]> uap-core.de Git - uwplayer.git/commitdiff
implement random playback
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 4 Sep 2022 17:51:24 +0000 (19:51 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 4 Sep 2022 17:51:24 +0000 (19:51 +0200)
application/main.c
application/playlist.c

index 42078dc376cd072ba54302625f071266b3368077..ecaf72bdf89530c609f1f33514081aeebeb8c164 100644 (file)
@@ -125,11 +125,11 @@ int main(int argc, char** argv) {
     if(load_config()) {
         return 1;
     }
-    
+   
     MainWindow *window = WindowCreate(display);
     toplevel_window = window->window;
     
-    // random numbers only used for creating tmp dirs
+    // random numbers used for creating tmp dirs and for random playback
     srand(time(NULL));
     
     WindowShow(window);
index 80d335bd914f8b05217eff8c9b9de38490771e88..1b311800fd8d211e4ee8745aa15c4b4e156992db 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "playlist.h"
 
+#include <stdlib.h>
+
 #include "player.h"
 #include "utils.h"
 
@@ -44,6 +46,8 @@ void PlayListPlayNext(MainWindow *win, bool force) {
         if(force) {
             current++;
         }
+    } else if(win->playlist.random) {
+        current = random() % len;
     } else if(current < len) {
         current++;
     } else if(win->playlist.autoplayFolder) {