summaryrefslogtreecommitdiff
path: root/mpv.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2016-11-23 10:20:49 +0100
committerjaseg <git@jaseg.net>2016-11-23 10:20:49 +0100
commiteb8b6a05d75a5abb55205f9859ce6f4223735946 (patch)
treed3e7605b3fce84ba332136fc5e930ff905916ca5 /mpv.py
parentefbf182723299e7edfe70dfd8b536419628fbc2a (diff)
downloadpython-mpv-eb8b6a05d75a5abb55205f9859ce6f4223735946.tar.gz
python-mpv-eb8b6a05d75a5abb55205f9859ce6f4223735946.tar.bz2
python-mpv-eb8b6a05d75a5abb55205f9859ce6f4223735946.zip
Clarify event thread handling in the README
Diffstat (limited to 'mpv.py')
-rw-r--r--mpv.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/mpv.py b/mpv.py
index de58908..c74e737 100644
--- a/mpv.py
+++ b/mpv.py
@@ -397,7 +397,7 @@ def _event_loop(event_handle, playback_cond, event_callbacks, message_handlers,
class MPV(object):
""" See man mpv(1) for the details of the implemented commands. """
- def __init__(self, *extra_mpv_flags, log_handler=None, **extra_mpv_opts):
+ def __init__(self, *extra_mpv_flags, log_handler=None, start_event_thread=True, **extra_mpv_opts):
""" Create an MPV instance.
Extra arguments and extra keyword arguments will be passed to mpv as options. """
@@ -419,11 +419,14 @@ class MPV(object):
self._key_binding_handlers = {}
self._playback_cond = threading.Condition()
self._event_handle = _mpv_create_client(self.handle, b'py_event_handler')
- loop = partial(_event_loop, self._event_handle, self._playback_cond, self._event_callbacks,
+ self._loop = partial(_event_loop, self._event_handle, self._playback_cond, self._event_callbacks,
self._message_handlers, self._property_handlers, log_handler)
- self._event_thread = threading.Thread(target=loop, name='MPVEventHandlerThread')
- self._event_thread.setDaemon(True)
- self._event_thread.start()
+ if start_event_thread:
+ self._event_thread = threading.Thread(target=self._loop, name='MPVEventHandlerThread')
+ self._event_thread.setDaemon(True)
+ self._event_thread.start()
+ else:
+ self._event_thread = None
if log_handler is not None:
self.set_loglevel('terminal-default')