aqt.mpv#

Exceptions#

MPVError

Common base class for all non-exit exceptions.

MPVProcessError

Common base class for all non-exit exceptions.

MPVCommunicationError

Common base class for all non-exit exceptions.

MPVCommandError

Common base class for all non-exit exceptions.

MPVTimeoutError

Common base class for all non-exit exceptions.

Classes#

MPVBase

Base class for communication with the mpv media player via unix socket

MPV

Class for communication with the mpv media player via unix socket

Module Contents#

exception aqt.mpv.MPVError#

Bases: Exception

Common base class for all non-exit exceptions.

exception aqt.mpv.MPVProcessError#

Bases: MPVError

Common base class for all non-exit exceptions.

exception aqt.mpv.MPVCommunicationError#

Bases: MPVError

Common base class for all non-exit exceptions.

exception aqt.mpv.MPVCommandError#

Bases: MPVError

Common base class for all non-exit exceptions.

exception aqt.mpv.MPVTimeoutError#

Bases: MPVError

Common base class for all non-exit exceptions.

class aqt.mpv.MPVBase(window_id=None, debug=False)#

Base class for communication with the mpv media player via unix socket based JSON IPC.

executable = None#
popenEnv: dict[str, str] | None = None#
default_argv = ['--idle', '--no-terminal', '--force-window=no', '--ontop', '--audio-display=no',...#
window_id = None#
debug = False#
is_running()#

Return True if the mpv process is still active.

ensure_running()#
close()#

Shutdown the mpv process and our communication setup.

class aqt.mpv.MPV(*args, **kwargs)#

Bases: MPVBase

Class for communication with the mpv media player via unix socket based JSON IPC. It adds a few usable methods and a callback API.

To automatically register methods as event callbacks, subclass this class and define specially named methods as follows:

def on_file_loaded(self):

# This is called for every ‘file-loaded’ event. …

def on_property_time_pos(self, position):

# This is called whenever the ‘time-pos’ property is updated. …

Please note that callbacks are executed inside a separate thread. The MPV class itself is completely thread-safe. Requests from different threads to the same MPV instance are synchronized.

register_callback(name, callback)#

Register a function callback for the event name.

unregister_callback(name, callback)#

Unregister a previously registered function callback for the event name.

register_property_callback(name, callback)#

Register a function callback for the property-change event on property name.

unregister_property_callback(name, callback)#

Unregister a previously registered function callback for the property-change event on property name.

command(*args, timeout=1)#

Execute a single command on the mpv process and return the result.

get_property(name)#

Return the value of property name.

set_property(name, value)#

Set the value of property name.