From 6eb42e6d4468ad161281125c77a41063f93380e1 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Tue, 21 Dec 2021 18:24:55 +0100 Subject: Added session manager, renamed solo-tool.py --- playlist.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'playlist.py') diff --git a/playlist.py b/playlist.py index 6e96534..5c52774 100644 --- a/playlist.py +++ b/playlist.py @@ -2,21 +2,23 @@ import logging class Playlist: def __init__(self, callback): - self.songList = list() - self.currentSong = None - self.setSongCallback = callback + self._songList = list() + self._currentSong = None + self._setSongCallback = callback def addSong(self, path): - self.songList.append(path) + self._songList.append(path) logging.debug(f"Added song: {path}") - if self.currentSong is None: - self.setCurrentSong(0) def setCurrentSong(self, index): - if index >= 0 and index < len(self.songList): - self.currentSong = index - self.setSongCallback(self.songList[index]) - logging.debug(f"Selected song: {self.currentSong}") + if index >= 0 and index < len(self._songList): + self._currentSong = index + self._setSongCallback(self._songList[index]) + logging.debug(f"Selected song: {self._currentSong}") def getCurrentSong(self): - return self.currentSong + index = self._currentSong + return self._songList[index] if index is not None else None + + def getSongs(self): + return self._songList -- cgit v1.2.3