curds: Don't loop len(1) playlists
We need to check if looping is true, even if length is one, before setting the current index. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
61d6221e30
commit
f765536c86
|
@ -45,6 +45,8 @@ class Playlist():
|
|||
if max == -1:
|
||||
return None
|
||||
elif max == 0:
|
||||
if self.loop == False and self.current == 0:
|
||||
return None
|
||||
self.current = 0
|
||||
elif self.random == True:
|
||||
self.current = (self.current + random.randint(1, max)) % max
|
||||
|
|
|
@ -174,8 +174,12 @@ class TestPlaylist(unittest.TestCase):
|
|||
track = tags.Track.lookup(os.path.join(path, "01 - Test Track 01.ogg"))
|
||||
|
||||
plist.add(track)
|
||||
self.assertEqual(plist.current, -1)
|
||||
self.assertEqual(plist.next(), track)
|
||||
self.assertEqual(plist.current, 0)
|
||||
self.assertEqual(plist.next(), None)
|
||||
self.assertEqual(plist.current, 0)
|
||||
|
||||
plist.set_loop(True)
|
||||
self.assertEqual(plist.next(), track)
|
||||
self.assertEqual(plist.current, 0)
|
||||
|
|
Loading…
Reference in New Issue