implement basic autoplay
[uwplayer.git] / application / player.c
index 4d0ef22..37c1b98 100644 (file)
@@ -39,6 +39,7 @@
 #include <pthread.h>
 
 #include "json.h"
+#include "utils.h"
 #include "settings.h"
 
 extern char **environ;
@@ -560,11 +561,27 @@ static void json_print(JSONValue *value, char *name, int indent) {
     }
 }
 
+static Boolean open_next_file(XtPointer data) {
+    char *file = data;
+    MainWindow *win = GetMainWindow();
+    if(win->file) {
+        free(file);
+    }
+    win->file = file;
+    PlayerOpenFile(win);
+    return 0;
+}
+
 void PlayerEOF(Player *p) {
     MainWindow *win = GetMainWindow();
     if(win->repeatTrack) {
         char *cmd = "{ \"command\": [\"set_property\", \"playback-time\", 0] }\n";
         write(p->ipc, cmd, strlen(cmd));
+    } else if(win->autoplayFolder) {
+        char *next_file = util_find_next_file(win->file);
+        if(next_file) {
+            AppExecProc(open_next_file, next_file);
+        }
     }
 }