From f9765b4fed5affb836b120612bd8ba1b38b7682e Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 21 Feb 2019 01:28:51 +0100 Subject: [PATCH] Support for extra arguments passed to VLC --- platypush/plugins/media/vlc.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/platypush/plugins/media/vlc.py b/platypush/plugins/media/vlc.py index 2b684785..3893be3f 100644 --- a/platypush/plugins/media/vlc.py +++ b/platypush/plugins/media/vlc.py @@ -21,10 +21,14 @@ class MediaVlcPlugin(MediaPlugin): * **vlc** executable on your system """ - def __init__(self, *args, fullscreen=False, volume=100, **kwargs): + def __init__(self, args=None, fullscreen=False, volume=100, *argv, **kwargs): """ Create the vlc wrapper. + :param args: List of extra arguments to pass to the VLC executable (e.g. + ``['--sub-language=en', '--snapshot-path=/mnt/snapshots']``) + :type args: list[str] + :param fullscreen: Set to True if you want media files to be opened in fullscreen by default (can be overridden by `.play()`) (default: False) :type fullscreen: bool @@ -33,10 +37,13 @@ class MediaVlcPlugin(MediaPlugin): :type volume: int """ - super().__init__(*args, **kwargs) + import vlc + super().__init__(*argv, **kwargs) + + self._args = args or [] + self._instance = vlc.Instance(*self._args) self._player = None - self._playback_rebounce_event = threading.Event() self._latest_seek = None self._default_fullscreen = fullscreen self._default_volume = volume @@ -58,8 +65,6 @@ class MediaVlcPlugin(MediaPlugin): ] if hasattr(vlc.EventType, evt)] def _init_vlc(self, resource): - import vlc - if self._player: self._player.stop() self._player = None @@ -67,7 +72,7 @@ class MediaVlcPlugin(MediaPlugin): for k,v in self._env.items(): os.environ[k] = v - self._player = vlc.MediaPlayer(resource) + self._player = self._instance.media_player_new(resource) for evt in self._watched_event_types(): self._player.event_manager().event_attach(