diff options
Diffstat (limited to 'playlist.py')
-rw-r--r-- | playlist.py | 24 |
1 files changed, 13 insertions, 11 deletions
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 |