aboutsummaryrefslogtreecommitdiffstats
path: root/player_mock.py
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2022-01-03 20:29:51 +0100
committerEddy Pedroni <eddy@0xf7.com>2022-01-03 20:29:51 +0100
commit6b23d5fef7ab1a936e133d620bd277274882b3a7 (patch)
tree063abde114b678bbf64dbe042ef50483c7a2a164 /player_mock.py
parentbfa2abe556269de927e399a0547b18126a78ff96 (diff)
Added playing state callback to player, refactored notifier to use it
Diffstat (limited to 'player_mock.py')
-rw-r--r--player_mock.py15
1 files changed, 15 insertions, 0 deletions
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()