Pause programmatically video player mpv

后端 未结 3 1403
慢半拍i
慢半拍i 2020-12-29 09:23

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 w

3条回答
  •  不知归路
    2020-12-29 10:15

    It's possible to control mpv through IPC. From the manual mpv(1):

    --input-ipc-server=
           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\). 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.
    

    A couple of examples:

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

    See mpv(1) to learn more.

    See also:

    • https://alexherbo2.github.io/blog/mpv/command-line-controller/
    • https://gist.github.com/dwgill/a66769e0edef69c04d3b

提交回复
热议问题