kljohann / mpv.el

control mpv for easy note taking
GNU General Public License v3.0
142 stars 14 forks source link

Failed to connect to MPV (continuation). Problems to in MAC. #31

Open AtomicNess123 opened 1 year ago

AtomicNess123 commented 1 year ago

I opened a similar issue time ago because I wasn't specifying a video file (stupid me!), but this time I am getting the error even when specifying it.

Debugger entered--Lisp error: (error "Failed to connect to mpv")
  signal(error ("Failed to connect to mpv"))
  error("Failed to connect to mpv")
  mpv-start("/Users/user/Desktop/vid.mp4")
  mpv-play("/Users/user/Desktop/vid.mp4")
  funcall-interactively(mpv-play "/Users/user/Desktop/vid.mp4")
  call-interactively(mpv-play record nil)
  command-execute(mpv-play record)
  helm-M-x-execute-command(mpv-play)
  helm-execute-selection-action-1()
  helm-execute-selection-action()
  funcall-interactively(helm-M-x nil)
  call-interactively(helm-M-x nil nil)
  command-execute(helm-M-x)

The reason why it isn't working could be because of pesky MAC security features. So I added Emacs and Ruby to Full Disk access. Did not work.

The mpv package works perfectly on Linux, it must therefore be a MAC security feature thats stopping it working.

The Emacs mpv package uses the json-ipc mpv interface, which creates a socket so that mpv can be controlled with emacs. So I tried the example in the mpv manual with socat to know if mpv is creating the socket and the json-ipc interface is working. However, it was working, so mpv is creating the socket and I can connect to it with socat.

So the issue must be with Emacs and the mpv package I wonder if emacs cant find the path to the mpv binary. So I added it:

(defcustom mpv-executable "/usr/local/bin/mpv"
  "Name or path to the mpv executable."
  :type 'file
  :group 'mpv)

Reloaded / pkilled Emacs, and restarted.

M-x mpv-play myvideo

It didn't work :(

soilc commented 1 year ago

I have the same problem on Debian 11 and on virtual machines Debian 10: "error: Failed to connect to mpv". I have in my init.el:

(require 'mpv)
(mpv-start "--idle=once")
(defcustom mpv-executable "/usr/bin/mpv"
  "Name or path to the mpv executable."
  :type 'file
  :group 'mpv)

At the same time: (mpv-version)"0.32.0".

Linden6 commented 11 months ago

I experienced this problem too on Debian.

When I increased the 'mpv-start-timeout' variable from the default value of 0.5 seconds to 5.0 seconds the issue disappeared. (It appears that on my machine mpv was simply taking longer than 0.5 seconds to start, and so triggering the 'failed to connect' timeout error message.)

The 'mpv-start-timeout' variable is a customizable variable as so can be changed interactively via 'M-x customize', or in your init.el file by adding for example: (customize-set-variable 'mpv-start-timeout 5.0)

soilc commented 10 months ago

Linden6: Thank you very much! This actually works on Debian!

kennethbruskiewicz commented 9 months ago

@AtomicNess123 What version of the package were you using?

Older versions of the package implement (mpv-start) with --input-unix-socket, which is an outdated flag. These older versions are on non NonGNU ELPA and I suspect on MELPA.

The Github repo has an updated version of the package, which uses --input-ipc-server instead. Installing with use-package and Quelpa:

(use-package mpv
  :quelpa (mpv :fetcher github :repo "kljohann/mpv.el"))