diff options
author | Eddy Pedroni <epedroni@pm.me> | 2024-11-09 20:35:56 +0100 |
---|---|---|
committer | Eddy Pedroni <epedroni@pm.me> | 2024-11-09 20:35:56 +0100 |
commit | cda8197669409689be291660f93cb288ab2d31b3 (patch) | |
tree | 81db9b0c7c0491e0737cbffb39af6b935c0dfeb8 /solo-tool-project/test/player_mock.py | |
parent | a2257a900d4fffd6f94b73f1c48c62370ed1d684 (diff) |
Migrate to project-based structure
Diffstat (limited to 'solo-tool-project/test/player_mock.py')
-rw-r--r-- | solo-tool-project/test/player_mock.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/solo-tool-project/test/player_mock.py b/solo-tool-project/test/player_mock.py new file mode 100644 index 0000000..3162e0f --- /dev/null +++ b/solo-tool-project/test/player_mock.py @@ -0,0 +1,71 @@ +class Player(): + STOPPED = 0 + PLAYING = 1 + PAUSED = 2 + + def __init__(self): + self.state = Player.STOPPED + self.rate = 1.0 + self.position = 0.0 + self.volume = 1.0 + self.currentSong = None + self.playingStateChangedCallback = None + self.playbackVolumeChangedCallback = 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 + + def setPlaybackRate(self, rate): + self.rate = rate + + def getPlaybackRate(self): + return self.rate + + def setPlaybackPosition(self, position): + self.position = position + + def getPlaybackPosition(self): + return self.position + + def setPlaybackVolume(self, volume): + changed = self.volume != volume + self.volume = volume + if changed: + self.playbackVolumeChangedCallback() + + def getPlaybackVolume(self): + return self.volume + + def setCurrentSong(self, path): + self.stop() + self.currentSong = path + + def setPlayingStateChangedCallback(self, callback): + self.playingStateChangedCallback = callback + + def simulatePlayingStateChanged(self): + self.playingStateChangedCallback() + + def setPlaybackVolumeChangedCallback(self, callback): + self.playbackVolumeChangedCallback = callback + + def simulatePlaybackVolumeChanged(self): + self.playbackVolumeChangedCallback() |