Pause software mpv video player

I would like to know if there is a way to send a message to a running process on Linux?

For example, is it possible to programmatically “pause” a video launched with mpv.

+4
source share
3 answers

To remotely control mpv(for example, from another terminal session), you can also start it using the option

--input-ipc-server=/tmp/mpvsocket

and control it by invoking commands as follows:

echo '{ "command": ["set_property", "pause", true] }' | socat - /tmp/mpvsocket

See details man mpvfor (a lot).

edit: see also mpv --list-properties

edit2: The easiest way I discovered to “pause” pause / play is

{"command": ["cycle", "pause"]}

+7
source

kill -s STOP $(pidof mpv) and kill -s CONT $(pidof mpv)

or better:

xdotool key --window "$(xdotool search --class mpv)" p

Key "P" is set by default to pause the video.

+4

mpv IPC. mpv(1):

--input-ipc-server=<filename>
       Enable the IPC support and create the listening socket at the given path.

       On  Linux and Unix, the given path is a regular filesystem path.
       On Windows, named pipes are used, so the path refers to the pipe namespace (\\.\pipe\<name>). If the \\.\pipe\ prefix is missing, mpv will add it automatically before creating the pipe, so --input-ipc-server=/tmp/mpv-socket and --input-ipc-server=\\.\pipe\tmp\mpv-socket are equivalent for IPC on Windows.

       See JSON IPC for details.

:

$ echo 'cycle pause'   | socat - /tmp/mpv-socket
$ echo 'playlist-prev' | socat - /tmp/mpv-socket
$ echo 'playlist-next' | socat - /tmp/mpv-socket

. mpv(1).

. :

+3
source

Source: https://habr.com/ru/post/1625983/


All Articles