aboutsummaryrefslogtreecommitdiffstats
path: root/playlist.py
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2021-12-21 08:16:55 +0100
committerEddy Pedroni <eddy@0xf7.com>2021-12-21 08:16:55 +0100
commit182a14f4b9aec4722f7f94ab44bf57356c6d71aa (patch)
treec2c3a683184a53ddc141fe33e02fc934b793d196 /playlist.py
parent1ca1fbcc001e27f46fc033f44ad5459bd0351bc9 (diff)
Added AB controller with some tests, minor refactor to playlist
Diffstat (limited to 'playlist.py')
-rw-r--r--playlist.py26
1 files changed, 7 insertions, 19 deletions
diff --git a/playlist.py b/playlist.py
index b175a08..6e96534 100644
--- a/playlist.py
+++ b/playlist.py
@@ -1,24 +1,10 @@
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):
+ def __init__(self, callback):
self.songList = list()
self.currentSong = None
- self.callback = setSongCallback
+ self.setSongCallback = callback
def addSong(self, path):
self.songList.append(path)
@@ -27,8 +13,10 @@ class Playlist:
self.setCurrentSong(0)
def setCurrentSong(self, index):
- if index < len(self.songList):
+ if index >= 0 and index < len(self.songList):
self.currentSong = index
- self.callback(self.songList[index])
+ self.setSongCallback(self.songList[index])
logging.debug(f"Selected song: {self.currentSong}")
-
+
+ def getCurrentSong(self):
+ return self.currentSong