Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

player: fix next_song when the following songs are bad #858

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions feeluown/player/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,16 @@ def next_song(self):
next_song = self._get_good_song(random_=True)
else:
current_index = self._songs.index(self.current_song)
if current_index == len(self._songs) - 1:
if self.playback_mode in (PlaybackMode.loop, PlaybackMode.one_loop):
next_song = self._get_good_song()
elif self.playback_mode == PlaybackMode.sequential:
next_song = None
is_last_song = current_index == len(self._songs) - 1
if is_last_song and self.playback_mode == PlaybackMode.sequential:
next_song = None
else:
next_song = self._get_good_song(base=current_index+1, loop=False)
if is_last_song:
base_index = 0
else:
base_index = current_index + 1
loop = self.playback_mode != PlaybackMode.sequential
next_song = self._get_good_song(base=base_index, loop=loop)
return next_song

@property
Expand Down
7 changes: 7 additions & 0 deletions tests/player/test_playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,10 @@ class Album:
# app_mock.library.album_upgrade.return_value = album
# When cover is a media object, prepare_metadata should also succeed.
await pl._metadata_mgr.prepare_for_song(ekaf_brief_song0)


def test_playlist_next_song(pl):
pl.mark_as_bad(pl.list()[1])
assert pl.next_song == pl.list()[0]
pl.playback_mode = PlaybackMode.sequential
assert pl.next_song is None
Loading