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 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): self.volume = volume def getPlaybackVolume(self): return self.volume def setCurrentSong(self, path): self.currentSong = path def setPlayingStateChangedCallback(self, callback): self.playingStateChangedCallback = callback def simulatePlayingStateChanged(self): self.playingStateChangedCallback()