blob: b175a08007fdf052ef06e3e66345381d7d493899 (
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
|
import logging
"""
class PlaylistModel(QAbstractListModel):
def __init__(self, medialist, *args, **kwargs):
super(PlaylistModel, self).__init__(*args, **kwargs)
self.medialist = medialist
def data(self, index, role):
if role == Qt.DisplayRole:
return self.medialist.item_at_index(index.row()).get_mrl()
def rowCount(self, index):
return self.medialist.count()
"""
class Playlist:
def __init__(self, setSongCallback):
self.songList = list()
self.currentSong = None
self.callback = setSongCallback
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 < len(self.songList):
self.currentSong = index
self.callback(self.songList[index])
logging.debug(f"Selected song: {self.currentSong}")
|