diff options
author | wm4 <wm4@nowhere> | 2015-02-21 16:01:50 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-02-21 16:26:37 +0100 |
commit | af435e0a027df4b2135488d76ee8b488a0474dfa (patch) | |
tree | f15f82111940c4179a86ec2b8fd3d0652ffe5000 /DOCS | |
parent | d71bbcbc98c1fa8a934ee656b13adda089a11681 (diff) | |
download | mpv-af435e0a027df4b2135488d76ee8b488a0474dfa.tar.bz2 mpv-af435e0a027df4b2135488d76ee8b488a0474dfa.tar.xz |
manpage: ipc: add a socat example
Requested, and should be quite good at giving an overview how it works.
Diffstat (limited to 'DOCS')
-rw-r--r-- | DOCS/man/ipc.rst | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/DOCS/man/ipc.rst b/DOCS/man/ipc.rst index 5a6f0f11f8..0edec05066 100644 --- a/DOCS/man/ipc.rst +++ b/DOCS/man/ipc.rst @@ -4,9 +4,7 @@ JSON IPC mpv can be controlled by external programs using the JSON-based IPC protocol. It can be enabled by specifying the path to a unix socket using the option ``--input-unix-socket``. Clients can connect to this socket and send commands to -the player or receive events from it. You can use the ``socat`` tool to send -commands (and receive reply) from the shell. See the ``--idle`` option how to -make mpv start without exiting immediately or playing a file. +the player or receive events from it. .. warning:: @@ -16,6 +14,38 @@ make mpv start without exiting immediately or playing a file. which can run arbitrary system commands. The use-case is controlling the player locally. This is not different from the MPlayer slave protocol. +Socat example +------------- + +You can use the ``socat`` tool to send commands (and receive reply) from the +shell. Assuming mpv was started with: + +:: + + mpv file.mkv --input-unix-socket=/tmp/mpvsocket + +Then you can control it using socat: + +:: + + > echo '{ "command": ["get_property", "playback-time"] }' | socat - /tmp/mpvsocket + {"data":190.482000,"error":"success"} + +In this case, socat copies data between stdin/stdout and the mpv socket +connection. + +See the ``--idle`` option how to make mpv start without exiting immediately or +playing a file. + +It's also possible to send input.conf style text-only commands: + +:: + + > echo 'show_text ${playback-time}' | socat - /tmp/mpvsocket + +But you won't get a reply over the socket. (This particular command shows the +playback time on the player's OSD.) + Protocol -------- |