summaryrefslogtreecommitdiff
path: root/mpv.py
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2016-08-13 01:28:33 +0200
committerjaseg <code@jaseg.net>2016-08-13 01:28:33 +0200
commitadfe131be97610955dbd381281074fcb8e8fc15a (patch)
treeec0385babcc687d8151eb1c712bcd974531bee04 /mpv.py
parentb6d2b514d58eaea4c28a547183fe7c1e73595ef7 (diff)
downloadpython-mpv-adfe131be97610955dbd381281074fcb8e8fc15a.tar.gz
python-mpv-adfe131be97610955dbd381281074fcb8e8fc15a.tar.bz2
python-mpv-adfe131be97610955dbd381281074fcb8e8fc15a.zip
Improve flag handling
Diffstat (limited to 'mpv.py')
-rw-r--r--mpv.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/mpv.py b/mpv.py
index eb30052..8caa86d 100644
--- a/mpv.py
+++ b/mpv.py
@@ -336,16 +336,19 @@ def _event_loop(event_handle, playback_cond, event_callbacks, property_handlers,
class MPV(object):
""" See man mpv(1) for the details of the implemented commands. """
- def __init__(self, log_handler=None, **kwargs):
+ def __init__(self, *extra_mpv_flags, log_handler=None, **extra_mpv_opts):
""" Create an MPV instance.
- Any kwargs given will be passed to mpv as options. """
+ Extra arguments and extra keyword arguments will be passed to mpv as options. """
+ self._event_thread = None
self.handle = _mpv_create()
_mpv_set_option_string(self.handle, b'audio-display', b'no')
istr = lambda o: ('yes' if o else 'no') if type(o) is bool else str(o)
- for k,v in kwargs.items():
+ for flag in extra_mpv_flags:
+ _mpv_set_option_string(self.handle, flag.encode('utf-8'), b'')
+ for k,v in extra_mpv_opts.items():
_mpv_set_option_string(self.handle, k.replace('_', '-').encode('utf-8'), istr(v).encode('utf-8'))
_mpv_initialize(self.handle)
@@ -374,7 +377,8 @@ class MPV(object):
def terminate(self):
self.handle, handle = None, self.handle
_mpv_terminate_destroy(handle)
- self._event_thread.join()
+ if self._event_thread:
+ self._event_thread.join()
def set_loglevel(self, level):
_mpv_request_log_messages(self._event_handle, level.encode('utf-8'))