From: Olaf Wintermann Date: Sun, 4 Sep 2022 17:51:24 +0000 (+0200) Subject: implement random playback X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=f650faf7190d0326f0a56ad549159bcfa6cd749b;p=uwplayer.git implement random playback --- diff --git a/application/main.c b/application/main.c index 42078dc..ecaf72b 100644 --- a/application/main.c +++ b/application/main.c @@ -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); diff --git a/application/playlist.c b/application/playlist.c index 80d335b..1b31180 100644 --- a/application/playlist.c +++ b/application/playlist.c @@ -22,6 +22,8 @@ #include "playlist.h" +#include + #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) {