From 3066dbcdd863342d3c9534886434d6e8aaa45367 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Tue, 4 Jan 2022 14:13:49 +0100 Subject: Added playback volume notification to VLC player --- player_mock.py | 3 +++ player_vlc.py | 5 ++++- solo_tool.py | 3 --- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/player_mock.py b/player_mock.py index 2fd343f..ee3801d 100644 --- a/player_mock.py +++ b/player_mock.py @@ -46,7 +46,10 @@ class Player(): return self.position def setPlaybackVolume(self, volume): + changed = self.volume != volume self.volume = volume + if changed: + self.playbackVolumeChangedCallback() def getPlaybackVolume(self): return self.volume diff --git a/player_vlc.py b/player_vlc.py index 9f8bb56..a7244bb 100644 --- a/player_vlc.py +++ b/player_vlc.py @@ -48,4 +48,7 @@ class Player: manager = self._player.event_manager() for e in events: manager.event_attach(e, callback) - self._playingStateChangedCallback = callback + + def setPlaybackVolumeChangedCallback(self, callback): + manager = self._player.event_manager() + manager.event_attach(vlc.EventType.MediaPlayerAudioVolume, callback) diff --git a/solo_tool.py b/solo_tool.py index 7933fce..bca5146 100644 --- a/solo_tool.py +++ b/solo_tool.py @@ -107,10 +107,7 @@ class SoloTool: return self._player.getPlaybackPosition() def setPlaybackVolume(self, volume): - previousVolume = self._player.getPlaybackVolume() self._player.setPlaybackVolume(volume) - if previousVolume != volume: - self._notifier.notify(Notifier.PLAYBACK_VOLUME_EVENT) def getPlaybackVolume(self): return self._player.getPlaybackVolume() -- cgit v1.2.3