Python API to MPV using JSON IPC
Project description
Python MPV JSONIPC
This implements an interface similar to python-mpv
, but it uses the JSON IPC protocol instead of the C API. This means
you can control external instances of MPV including players like SMPlayer, and it can use MPV players that are prebuilt
instead of needing libmpv1
. It may also be more resistant to crashes such as Segmentation Faults, but since it isn't
directly communicating with MPV via the C API the performance will be worse.
Please note that this only implements the subset of python-mpv
that is used by plex-mpv-shim
and
jellyfin-mpv-shim
. Other functionality has not been implemented.
Installation
sudo pip3 install python-mpv-jsonipc
Basic usage
Create an instance of MPV. You can use an already running MPV or have the library start a managed copy of MPV. Command arguments can be specified when initializing MPV if you are starting a managed copy of MPV.
Please also see the API Documentation.
from python_mpv_jsonipc import MPV
# Uses MPV that is in the PATH.
mpv = MPV()
# Use MPV that is running and connected to /tmp/mpv-socket.
mpv = MPV(start_mpv=False, ipc_socket="/tmp/mpv-socket")
# Uses MPV that is found at /path/to/mpv.
mpv = MPV(mpv_location="/path/to/mpv")
# After you have an MPV, you can read and set (if applicable) properties.
mpv.volume # 100.0 by default
mpv.volume = 20
# You can also send commands.
mpv.command_name(arg1, arg2)
# Bind to key press events with a decorator
@mpv.on_key_press("space")
def space_handler():
pass
# You can also observe and wait for properties.
@mpv.property_observer("eof-reached")
def handle_eof(name, value):
pass
# Or simply wait for the value to change once.
mpv.wait_for_property("duration")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for python-mpv-jsonipc-1.1.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d348b275504778d83e3ba9e6757c2f1190d2c03b7fd93e68ea51e9458e84166d |
|
MD5 | 0261879c502982b4c542b08aac96328f |
|
BLAKE2b-256 | a8ec8899310cf2c88592af2bb478de104596e9e5e1939e7058f1917db3368140 |
Hashes for python_mpv_jsonipc-1.1.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 799381daba7863cadc4f72174e0c29641c051aa029b27246dccd7c2a2912311f |
|
MD5 | dadbfc54a6db946d7b5c2c19b7b8f14a |
|
BLAKE2b-256 | 89eab394cda2f0675a0a664ebb8810f26e47dbee0ef9a849d2e1726116d0469f |