I want to pause the video in any window
THX
Which OS?
For Linux, something like this: http://unix.stackexchange.com/a/87839
For Windows, I use this: https://github.com/siikamiika/scripts/blob/master/windows/mpv_vol.ahk#L7
OS X
Oh, of course there's http://mpv.io/manual/stable/#json-ipc as well. You could try to start mpv with --input-unix-socket=/tmp/mpvsocket and using echo 'cycle pause' | socat - /tmp/mpvsocket, assuming it works on OS X and you have socat installed.
Or even simpler, first mkfifo /tmp/mpvfifo, then put input-file=/tmp/mpvfifo to mpv conf and just echo 'cycle pause\n' > /tmp/mpvfifo
I set a shortcut Alt+P and start mpg with it, run echo 'cycle pause' | socat - /tmp/mpvsocket, while still can't pause the video?
Maybe it needs a newline?
I tested echo 'cycle pause\n' > /tmp/mpvfifo, nothing happened. Only when I use it in mpv window, it can be paused
So you had input-file=/tmp/mpvfifo in mpv.conf and you had created /tmp/mpvfifo with mkfifo before echoing to it? Anyway, I can't test it right now so better wait for someone else to help, sorry.
Yes, I have done these steps.
I found I can paused the video when I use the command echo 'cycle pause' | socat - /tmp/mpvsocket. But I want to paused it when I use Alt+P(I set it in input.conf) in other window like text editor.
Thank you anyway.
Oh that was the problem. You don't use input.conf for that, you use some other mac tool that lets you bind scripts to keys. I can't suggest one because I don't use mac, but I'm sure you can find one from Google.
Thank you very much. It works.
I use FastScripts and make a shell script to do it!
You know you could also use the usual iTunes media keys to control mpv?
http://mpv.io/manual/master/#options-input-media-keys
@Argon- Yes, however, those only work while the window is active.
There's no way to have MPV itself grab those keys from the background like VLC can, at least for now (and, since the issue has been "closed" because there are OS-specific workarounds that depend on 3rd-party software, probably for the forseeable future)
Yes, however, those only work while the window is active.
Works fine for me with background video windows on OS X 10.9.
Yeah, but that's OSX-specific code.
@wm4 so, just to confirm: currently, there is NO WAY to have my media control keys bound to MPV without 3rd-party software such as autohotkey?
No. I also don't think this is mpv's job. For global hotkeys, some external software has to coordinate to what programs to dispatch the key, obviously. On Linux, mpris is often used, for which some Lua script is available. Don't know how this works on Windows, or what the mpv OSX implementation does.
@wm4 Ah, speaking of MPRIS support!
The package lua-mpris that's recommended on the wiki is dying of bit rot… it hasn't recieved any commits in almost a year and a half, no longer works properly with recent MPRIS stacks, and the owner rarely logs on anymore.
Is there any chance MPRIS support could be added to MPV (as a compile-time optional), or at least have some kind of officially sanctioned/developed plugin for it?
(The reason I mention this in this thread is that, if I recall correctly, most Linux DEs will have media key support already there, in the MPRIS support in the sound applet)
Not by me.
Or even simpler, first
mkfifo /tmp/mpvfifo, then putinput-file=/tmp/mpvfifoto mpv conf and justecho 'cycle pause\n' > /tmp/mpvfifo
Just for the record: echo 'cycle pause' > /tmp/mpvfifo is what works on Linux since the GNU version of echo already puts a newline but doesn't interpret backslash escapes unless -e is specified.
Most helpful comment
Oh, of course there's http://mpv.io/manual/stable/#json-ipc as well. You could try to start mpv with
--input-unix-socket=/tmp/mpvsocketand usingecho 'cycle pause' | socat - /tmp/mpvsocket, assuming it works on OS X and you havesocatinstalled.