aqt.mpv
=======

.. py:module:: aqt.mpv


Exceptions
----------

.. autoapisummary::

   aqt.mpv.MPVError
   aqt.mpv.MPVProcessError
   aqt.mpv.MPVCommunicationError
   aqt.mpv.MPVCommandError
   aqt.mpv.MPVTimeoutError


Classes
-------

.. autoapisummary::

   aqt.mpv.MPVBase
   aqt.mpv.MPV


Module Contents
---------------

.. py:exception:: MPVError

   Bases: :py:obj:`Exception`


   Common base class for all non-exit exceptions.


.. py:exception:: MPVProcessError

   Bases: :py:obj:`MPVError`


   Common base class for all non-exit exceptions.


.. py:exception:: MPVCommunicationError

   Bases: :py:obj:`MPVError`


   Common base class for all non-exit exceptions.


.. py:exception:: MPVCommandError

   Bases: :py:obj:`MPVError`


   Common base class for all non-exit exceptions.


.. py:exception:: MPVTimeoutError

   Bases: :py:obj:`MPVError`


   Common base class for all non-exit exceptions.


.. py:class:: MPVBase(window_id=None, debug=False)

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


   .. py:attribute:: executable
      :value: None



   .. py:attribute:: popenEnv
      :type:  dict[str, str] | None
      :value: None



   .. py:attribute:: default_argv
      :value: ['--idle', '--no-terminal', '--force-window=no', '--ontop', '--audio-display=no',...



   .. py:attribute:: window_id
      :value: None



   .. py:attribute:: debug
      :value: False



   .. py:method:: is_running()

      Return True if the mpv process is still active.



   .. py:method:: ensure_running()


   .. py:method:: close()

      Shutdown the mpv process and our communication setup.



.. py:class:: MPV(*args, **kwargs)

   Bases: :py:obj:`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.


   .. py:method:: register_callback(name, callback)

      Register a function `callback` for the event `name`.



   .. py:method:: unregister_callback(name, callback)

      Unregister a previously registered function `callback` for the event
      `name`.



   .. py:method:: register_property_callback(name, callback)

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



   .. py:method:: unregister_property_callback(name, callback)

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



   .. py:method:: command(*args, timeout=1)

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



   .. py:method:: get_property(name)

      Return the value of property `name`.



   .. py:method:: set_property(name, value)

      Set the value of property `name`.



