summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-21 16:01:50 +0100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-02-24 12:12:34 +0900
commitb4abc0a03751da7974a2c201bbd3d042d50c7566 (patch)
tree71458ead5453e83f186526846f978b209b9fd533
parent192318a216d63d3163d551a3e3e493156ae60f3d (diff)
downloadmpv-b4abc0a03751da7974a2c201bbd3d042d50c7566.tar.bz2
mpv-b4abc0a03751da7974a2c201bbd3d042d50c7566.tar.xz
manpage: ipc: add a socat example
Requested, and should be quite good at giving an overview how it works. (cherry picked from commit af435e0a027df4b2135488d76ee8b488a0474dfa)
-rw-r--r--DOCS/man/ipc.rst36
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
--------