blob: 288073370f10b3cb1832b35e30b1121ca1e4f1e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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)
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)
|