diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2022-01-04 14:58:39 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2022-01-04 14:58:39 +0100 |
commit | 3eed7537f8cc0221a81951b24ef965f6b7f35d6e (patch) | |
tree | 11158ffd5c6d4d7403e6bde07308b0c3c4e65999 /solo_tool.py | |
parent | 3066dbcdd863342d3c9534886434d6e8aaa45367 (diff) |
Added song and AB limits change notification
Diffstat (limited to 'solo_tool.py')
-rw-r--r-- | solo_tool.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/solo_tool.py b/solo_tool.py index bca5146..fee7e4a 100644 --- a/solo_tool.py +++ b/solo_tool.py @@ -30,13 +30,22 @@ class SoloTool: self._sessionManager.addSong(path) def setSong(self, index): + changed = index != self._playlist.getCurrentSongIndex() self._playlist.setCurrentSong(index) + if changed: + self._notifier.notify(Notifier.CURRENT_SONG_EVENT) def nextSong(self): + previous = self._playlist.getCurrentSongIndex() self._playlist.nextSong() + if previous != self._playlist.getCurrentSongIndex(): + self._notifier.notify(Notifier.CURRENT_SONG_EVENT) def previousSong(self): + previous = self._playlist.getCurrentSongIndex() self._playlist.previousSong() + if previous != self._playlist.getCurrentSongIndex(): + self._notifier.notify(Notifier.CURRENT_SONG_EVENT) def getSongs(self): return self._playlist.getSongs() @@ -45,7 +54,10 @@ class SoloTool: self._abController.storeLimits(aLimit, bLimit) def loadAbLimits(self, index): + changed = index != self._abController.getLoadedIndex() self._abController.loadLimits(index) + if changed: + self._notifier.notify(Notifier.CURRENT_AB_EVENT) def setAbLimits(self, aLimit, bLimit): self._abController.setLimits(aLimit, bLimit) @@ -61,10 +73,16 @@ class SoloTool: self._abController.setEnable(enable) def nextStoredAbLimits(self): + previous = self._abController.getLoadedIndex() self._abController.nextStoredAbLimits() + if previous != self._abController.getLoadedIndex(): + self._notifier.notify(Notifier.CURRENT_AB_EVENT) def previousStoredAbLimits(self): + previous = self._abController.getLoadedIndex() self._abController.previousStoredAbLimits() + if previous != self._abController.getLoadedIndex(): + self._notifier.notify(Notifier.CURRENT_AB_EVENT) def jumpToA(self): a = self._abController.getCurrentLimits()[0] @@ -121,3 +139,9 @@ class SoloTool: def registerPlaybackRateCallback(self, callback): self._notifier.registerCallback(Notifier.PLAYBACK_RATE_EVENT, callback) + def registerCurrentSongCallback(self, callback): + self._notifier.registerCallback(Notifier.CURRENT_SONG_EVENT, callback) + + def registerCurrentAbLimitsCallback(self, callback): + self._notifier.registerCallback(Notifier.CURRENT_AB_EVENT, callback) + |