IPC: socat equivalent on Windows #14703
Hrxn
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Important Information
mpv 0.28.0 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
Windows 10, Version 10.0.19043.1645
mpv.io
.. this was kinda official I think, back then when @lachs0r made releases 😄The correct way to make use of the JSON IPC interface on Windows?
As the mpv manual mentions here
Okay, so I gave it shot, and wanted to know how to best progress from here on..
Required First Step
mpv --input-ipc-server=\\.\pipe\ipc_mpv --idle=yes
(yes, I know how to start it as a separate process without any window etc., but it's good for debugging to do it like this)
Put this into a
.ps1
file, e.g.mp.ipc.ps1
and make it accessible via PATHThis can now be used like this, for example:
mp.ipc '{ "command": ["get_property", "idle-active"] }'
And it basically works, because it's not just sending commands, but also receiving replies from the terminal.
I'm just not sure if this is really the optimal way to do it. Because you have to be careful when using any
read()-like
method on the stream, otherwise the script will simply not terminate. It's not immediately obvious, but there are two ways to send commands to mpv here, the JSON messages and simple strings like as in the input commands (same format as input.conf, basically). mpv receives and handles both kinds just fine, but the latter will not trigger any reply of any kind, apparently, and will bork any reads.This script does not really do any handling with incoming reply messages, but it can easily be extended, and I checked that it works with simple, normal replies.
Of course, commands like
{ "command": ["observe_property", 1, "volume"] }
work a bit different here, and I'm not sure how to approach this yet. A similar issue with the event messages that get sent back. I can see them, but I don't know how to properly handle them. As I understand it from the manual, every single event (just like any message, etc.) is separated by the newline char (\n
),but how and when do these events end, for example, after sending a
"loadfile"
command? Is there any way to know this in advance?Or does the stream has to be read and handled constantly, all the time?
Another question, which might be an actual issue, unlike everything else mentioned in here so far, is that when sending this command:
{ "command": ["loadfile", "E:/path/to/file.mp4", "append"] }
, I can see that this gets added to the internal default playlist (is that what it's called?), but if I follow this up with{ "command": ["playlist-next"] }
, nothing is happening. Is this expected?I mean, when checking for
{ "command": ["get_property", "pause"] }
I see that this isfalse
, but playback does simply not start?Edit:
Small addendum:
I use some value for
impersonationLevel
when using the constructor for NamedPipeClientStream above, but I think this might be entirely optional. I'm not really sure what this does, actually. Just wanted to mention this, just in case.Beta Was this translation helpful? Give feedback.
All reactions