-
Notifications
You must be signed in to change notification settings - Fork 237
Move to JSON IPC API for mpv using iwaltons3's library (#261) #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I have tested it with mpv 0.23, 0.29.0 and 0.32 - it works except for needing to wait for ipc |
|
The library currently assumes MPV is running and has IPC available if Of course you can verify that the socket/pipe is already open before calling the constructor. Just be careful as Windows names pipes behave oddly if you check them twice in a short period of time. |
|
With 76439a4 I've tried moving over to managed mpv as per @iwalton3's suggestion to see if that fixes the issue raised by @daniel-123. When testing the latest commit please pay close attention to:
|
|
If there is a problem with it detecting events such as window close, you can catch them with an event handler: https://github.com/iwalton3/jellyfin-mpv-shim/blob/master/jellyfin_mpv_shim/player.py#L111 |
|
@iwalton3 In terms of event handling, if two scripts both register for the same on_key_press event (e.g. "space" or "CLOSE_WIN" ) then will mpv only actually honour one of them? That was my vague recollection from looking into it a long time ago, but maybe I'm wrong or out of date. |
|
Yes if you bind a key, it will prevent all behavior from all previous key binds for that key, including the default ones. |
daniel-123
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my tests as of current commit it works with 0.23.0 so I don't see much of a reason to raise required version all the way up to 0.29.0.
daniel-123
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quitting mpv raises an exception
EventHandler caught exception from (<bound method MpvPlayer.mpv_log_handler of <syncplay.players.mpv.MpvPlayer object at 0x7f197c031d30>>, ('info', 'cplayer', 'Exiting... (Quit)')).
Expected behavior would be to just quit Syncplay instead.
The best way to handle this would probably be to rebind |
I feel iffy about rebinding keys. It won't do anything if somebody uses different key to quit mpv (or just clicks the X). It also won't handle the situation where mpv crashes for some reason. I think it's just much simpler to ensure consistent behavior if Syncplay quits the instant mpv process is no longer there regardless of the reason. Edit: an exception further down is a simple |
Yeah that is probably your best bet, since it still works even if it is connecting to a copy the user launches. That would have to be caught in the separate pipe implementations and sent back as some kind of event (since they're separate threads). |
|
It looks like the actual "BrokenPipeError: [Errno 32] Broken pipe" doesn't happen until you try call something on the MPV instance after it has crashed. (Currently the broken pipe is ignored in the actual socket implementations.) I'll add a callback you can register to know when MPV terminates. |
|
Thanks so much for working on this @Et0h! Can we expect any kind of release (stable or otherwise) once this is merged? I would love to try it out at that point. |
If no showstoppers are reported then I expect this PR will be merged into the main branch before the end of this week after it has been tested on Mac. I'm hoping to get at a release candidate of Syncplay v1.6.5 out before the end of the month. |
…Syncplay#310) * Separate mpv from mplayer, increase min mpv ver to >= 0.17, refactor * Further separation of mpv from mplayer * Fix reference to isASCII * Add iwalton3's Python MPV JSONIPC library (Apache 2.0) * Move to JSON IPC API for mpv using iwaltons3's library (Syncplay#261) * Add empty init in Python MPV JSONIPC to make py2exe happy * Use managed version of Python MPV JSONIPC to improve initialisation reliability * Set mpv min version to >=0.29.0 to ensure compatibility * Allow mpv >=0.23.0 based on daniel-123's tests * Update mpv compatibility message * Revert to old OSC compat message * Removed mpv option that's no longer used afer switching to IPC. * Update python-mpv-jsonipc to v1.1.11 * Use python-mpv-jsonipc's mpv quit handler * Shorten mpv paused/position update message Co-authored-by: daniel-123 <[email protected]>
…Syncplay#310) * Separate mpv from mplayer, increase min mpv ver to >= 0.17, refactor * Further separation of mpv from mplayer * Fix reference to isASCII * Add iwalton3's Python MPV JSONIPC library (Apache 2.0) * Move to JSON IPC API for mpv using iwaltons3's library (Syncplay#261) * Add empty init in Python MPV JSONIPC to make py2exe happy * Use managed version of Python MPV JSONIPC to improve initialisation reliability * Set mpv min version to >=0.29.0 to ensure compatibility * Allow mpv >=0.23.0 based on daniel-123's tests * Update mpv compatibility message * Revert to old OSC compat message * Removed mpv option that's no longer used afer switching to IPC. * Update python-mpv-jsonipc to v1.1.11 * Use python-mpv-jsonipc's mpv quit handler * Shorten mpv paused/position update message Co-authored-by: daniel-123 <[email protected]>
This should allow Syncplay to support mpv >0.30.0. Raises minimum mpv version to >= 0.17.0.
Many thanks to @iwalton3 for his Python MPV JSONIPC library which is available from https://github.com/iwalton3/python-mpv-jsonipc/