audio: Pick next track from the Previous playlist first

This lets us move up and down the Previous playlist through the buttons,
in case we go back too far by accident.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-11-20 15:56:48 -05:00
parent 27ad8d72b4
commit 594f7991f2
2 changed files with 12 additions and 3 deletions

View File

@ -43,10 +43,15 @@ class Player(bass.BassPlayer):
self.change_track(track, reset=True, add_prev=add_prev)
self.play()
def next(self): self.play_track(self.playlist.next_track())
def next(self):
if track := db.user.Table.find("Previous").next_track():
self.play_track(track, add_prev=False)
else:
self.play_track(self.playlist.next_track())
def previous(self):
previous = db.user.Table.find("Previous")
self.play_track(previous.previous_track(), add_prev=False)
if track := db.user.Table.find("Previous").previous_track():
self.play_track(track, add_prev=False)
def set_playlist(self, plist):
if plist is None:

View File

@ -140,3 +140,7 @@ class TestPlayer(unittest.TestCase):
play.previous()
self.assertEqual(play.track, track0)
self.assertEqual(self.changed, (track1, track0))
play.next()
self.assertEqual(play.track, track1)
self.assertEqual(self.changed, (track0, track1))