From 548b6a53feb7703e8a42e2441f8baec30133c493 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Thu, 7 May 2020 09:55:24 +0200
Subject: [PATCH] Force play state when loading a file

---
 src/module/mpv.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/module/mpv.c b/src/module/mpv.c
index 3f101b9c..65311b8f 100644
--- a/src/module/mpv.c
+++ b/src/module/mpv.c
@@ -103,12 +103,17 @@ lmpv_load_file(mpv_handle *ctx, const char *file)
 {
     RETURN_UNLESS(ctx, "Missing mpv ctx", 1);
     RETURN_IF(access(file, R_OK), "Failed to read file", 1);
-    const char *cmd[] = {"loadfile", file, "replace", NULL};
+    const char *cmd1[] = { "loadfile", file, "replace", NULL };
+    const char *cmd2[] = { "set", "pause", "0", NULL };
     int status;
-    if ((status = mpv_command_async(ctx, 0, cmd)) < 0) {
+    if ((status = mpv_command_async(ctx, 0, cmd1)) < 0) {
         LOG_ERROR_SCT("WINDOW", "Failed to add '%s': %s", file, mpv_error_string(status));
         return 1;
     }
+    if ((status = mpv_command_async(ctx, 0, cmd2)) < 0) {
+        LOG_ERROR_SCT("WINDOW", "Failed to set state to play: %s", mpv_error_string(status));
+        return 1;
+    }
     return 0;
 }
 
-- 
GitLab