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_mock.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'player_mock.py') diff --git a/player_mock.py b/player_mock.py index 5aad769..92da675 100644 --- a/player_mock.py +++ b/player_mock.py @@ -9,15 +9,25 @@ class Player(): self.position = 0.0 self.volume = 1.0 self.currentSong = None + self.playingStateChangedCallback = None def play(self): + previousState = self.state self.state = Player.PLAYING + if previousState != Player.PLAYING: + self.playingStateChangedCallback() def stop(self): + previousState = self.state self.state = Player.STOPPED + if previousState != Player.STOPPED: + self.playingStateChangedCallback() def pause(self): + previousState = self.state self.state = Player.PAUSED + if previousState != Player.PAUSED: + self.playingStateChangedCallback() def isPlaying(self): return self.state == Player.PLAYING @@ -43,3 +53,8 @@ class Player(): def setCurrentSong(self, path): self.currentSong = path + def setPlayingStateChangedCallback(self, callback): + self.playingStateChangedCallback = callback + + def simulatePlayingStateChanged(self): + self.playingStateChangedCallback() -- cgit v1.2.3