aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/src/solo_tool/playlist.py
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2024-11-09 20:35:56 +0100
committerEddy Pedroni <epedroni@pm.me>2024-11-09 20:35:56 +0100
commitcda8197669409689be291660f93cb288ab2d31b3 (patch)
tree81db9b0c7c0491e0737cbffb39af6b935c0dfeb8 /solo-tool-project/src/solo_tool/playlist.py
parenta2257a900d4fffd6f94b73f1c48c62370ed1d684 (diff)
Migrate to project-based structure
Diffstat (limited to 'solo-tool-project/src/solo_tool/playlist.py')
-rw-r--r--solo-tool-project/src/solo_tool/playlist.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/solo-tool-project/src/solo_tool/playlist.py b/solo-tool-project/src/solo_tool/playlist.py
new file mode 100644
index 0000000..bbfd8f5
--- /dev/null
+++ b/solo-tool-project/src/solo_tool/playlist.py
@@ -0,0 +1,40 @@
+class Playlist:
+ def __init__(self, callback):
+ self._songList = list()
+ self._currentSong = None
+ self._setSongCallback = callback
+
+ def addSong(self, path):
+ self._songList.append(path)
+
+ def setCurrentSong(self, index):
+ if index >= 0 and index < len(self._songList):
+ self._currentSong = index
+ self._setSongCallback(self._songList[index])
+
+ def getCurrentSong(self):
+ index = self._currentSong
+ return self._songList[index] if index is not None else None
+
+ def getCurrentSongIndex(self):
+ return self._currentSong
+
+ def getSongs(self):
+ return self._songList
+
+ def clear(self):
+ self.__init__(self._setSongCallback)
+
+ def nextSong(self):
+ if self._currentSong is None:
+ nextSong = 0
+ else:
+ nextSong = self._currentSong + 1
+ self.setCurrentSong(nextSong)
+
+ def previousSong(self):
+ if self._currentSong is None:
+ prevSong = 0
+ else:
+ prevSong = self._currentSong - 1
+ self.setCurrentSong(prevSong)