aboutsummaryrefslogtreecommitdiffstats
path: root/playlist.py
blob: 6e9653443e67491530872909cad18fc5fb65d01b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import logging

class Playlist:
    def __init__(self, callback):
        self.songList = list()
        self.currentSong = None
        self.setSongCallback = callback

    def addSong(self, 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}")
    
    def getCurrentSong(self):
        return self.currentSong