From 6b23d5fef7ab1a936e133d620bd277274882b3a7 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Mon, 3 Jan 2022 20:29:51 +0100 Subject: Added playing state callback to player, refactored notifier to use it --- player_vlc.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'player_vlc.py') diff --git a/player_vlc.py b/player_vlc.py index c0eadf9..9f8bb56 100644 --- a/player_vlc.py +++ b/player_vlc.py @@ -38,3 +38,14 @@ class Player: def setCurrentSong(self, path): media = vlc.Media(path) self._player.set_media(media) + + def setPlayingStateChangedCallback(self, callback): + events = [ + vlc.EventType.MediaPlayerStopped, + vlc.EventType.MediaPlayerPlaying, + vlc.EventType.MediaPlayerPaused + ] + manager = self._player.event_manager() + for e in events: + manager.event_attach(e, callback) + self._playingStateChangedCallback = callback -- cgit v1.2.3