add playlist data structure
[uwplayer.git] / application / player.c
index 255f7cb..42f09e7 100644 (file)
@@ -41,6 +41,7 @@
 #include "json.h"
 #include "utils.h"
 #include "settings.h"
+#include "playlist.h"
 
 extern char **environ;
 
@@ -572,27 +573,19 @@ static void json_print(JSONValue *value, char *name, int indent) {
     }
 }
 
-static Boolean open_next_file(XtPointer data) {
-    char *file = data;
+static Boolean play_next(XtPointer data) {
     MainWindow *win = GetMainWindow();
-    if(win->file) {
-        free(file);
-    }
-    win->file = file;
-    PlayerOpenFile(win);
+    PlayListPlayNext(win, false);    
     return 0;
 }
 
 void PlayerEOF(Player *p) {
     MainWindow *win = GetMainWindow();
-    if(win->repeatTrack) {
+    if(win->playlist.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);
-        }
+    } else {
+        AppExecProc(play_next, NULL);
     }
 }