curds: Change PlaylistManager.current into a list
I'm going to keep a list of playlists that have been selected so we can switch playlists automatically when one ends. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
a7802b8794
commit
b22ffbf5aa
|
@ -92,25 +92,25 @@ class PlaylistManager(PlaylistManagerBase):
|
|||
self.append(GenreManager())
|
||||
self.append(Placeholder())
|
||||
self.append(LibraryManager())
|
||||
self.current = self.lookup("Collection")
|
||||
self.current = [ self.lookup("Collection") ]
|
||||
self.track = None
|
||||
|
||||
def next(self):
|
||||
self.track = self.current.next()
|
||||
self.track = self.current[0].next()
|
||||
self.lookup("Previous").add(self.track)
|
||||
return self.track
|
||||
|
||||
def peek(self, n):
|
||||
cur = self.current.current
|
||||
cur = self.current[0].current
|
||||
state = random.getstate()
|
||||
res = [ ]
|
||||
|
||||
for i in range(n):
|
||||
t = self.current.next()
|
||||
t = self.current[0].next()
|
||||
if t != None:
|
||||
res.append(t)
|
||||
|
||||
self.current.current = cur
|
||||
self.current[0].current = cur
|
||||
random.setstate(state)
|
||||
return res
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
self.assertIsInstance(self.playman.lookup("Library"), manager.PlaylistManagerBase)
|
||||
self.assertIsInstance(self.playman.lookup("Library"), list)
|
||||
|
||||
self.assertEqual(self.playman.current, self.playman.lookup("Collection"))
|
||||
self.assertEqual(self.playman.current, [ self.playman.lookup("Collection") ])
|
||||
self.assertEqual(self.playman.track, None)
|
||||
|
||||
def test_manager_indexing(self):
|
||||
|
@ -223,3 +223,10 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
|
||||
for i in range(5):
|
||||
self.assertEqual(self.playman.next(), tracks[i])
|
||||
|
||||
def test_manager_select_playlist(self):
|
||||
clist = self.playman.lookup("Collection")
|
||||
plist = self.playman.lookup("Library").lookup(test_library, allocate=True)
|
||||
library.join()
|
||||
|
||||
self.assertEqual(self.playman.current, [ clist ])
|
||||
|
|
Loading…
Reference in New Issue