diff options
author | jaseg <code@jaseg.net> | 2016-08-13 01:28:33 +0200 |
---|---|---|
committer | jaseg <code@jaseg.net> | 2016-08-13 01:28:33 +0200 |
commit | adfe131be97610955dbd381281074fcb8e8fc15a (patch) | |
tree | ec0385babcc687d8151eb1c712bcd974531bee04 /mpv.py | |
parent | b6d2b514d58eaea4c28a547183fe7c1e73595ef7 (diff) | |
download | python-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.py | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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')) |