add --player-operation-mode=pseudo-gui option to mpv
[uwplayer.git] / application / player.c
index 4764e98..8c1909c 100644 (file)
@@ -39,6 +39,7 @@
 #include <pthread.h>
 
 #include "json.h"
+#include "utils.h"
 #include "settings.h"
 
 extern char **environ;
@@ -138,14 +139,16 @@ static int start_player_process(Player *player, MainWindow *win) {
     
     // create player arg list
     char *args[32];
-    args[0] = player_bin;
-    args[1] = "-wid";
-    args[2] = wid_arg;
-    args[3] = "--no-terminal";
-    args[4] = log_arg;
-    args[5] = ipc_arg;
-    args[6] = win->file;
-    args[7] = NULL;
+    int ac = 0;
+    args[ac++] = player_bin;
+    args[ac++] = "-wid";
+    args[ac++] = wid_arg;
+    args[ac++] = "--no-terminal";
+    args[ac++] = "--player-operation-mode=pseudo-gui";
+    args[ac++] = log_arg;
+    args[ac++] = ipc_arg;
+    args[ac++] = win->file;
+    args[ac++] = NULL;
     
     posix_spawn_file_actions_t actions;
     posix_spawn_file_actions_init(&actions);
@@ -560,9 +563,28 @@ 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) {
-    char *cmd = "{ \"command\": [\"set_property\", \"playback-time\", 0] }\n";
-    write(p->ipc, cmd, strlen(cmd));
+    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);
+        }
+    }
 }
 
 void PlayerHandleInput(MainWindow *win, Player *p, XmDrawingAreaCallbackStruct *cb) {