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 getSongs(self): return self._songList def clear(self): self.__init__(self._setSongCallback)