From 96e2cc1b95b786ab5d6f82a5cb4f29dd6c1aca21 Mon Sep 17 00:00:00 2001 From: Milan Herbig Date: Sat, 20 Aug 2016 16:24:33 +0200 Subject: [PATCH] fixed crash when removing last item from playlist --- components/media.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/media.py b/components/media.py index 42c2603..3cabc95 100644 --- a/components/media.py +++ b/components/media.py @@ -231,12 +231,15 @@ def removeItem(self, remove_index): if must_change_song: logger.debug("Currently playing media has been removed from playlist, selecting next one.") if not self.shuffled_playlist: - logger.debug("There is no other media left!") - return - - self.play(item_playlist_id=self.shuffled_playlist[self.shuffled_playlist_current_index]) - if not restore_playing: + logger.debug("There is no next media left!") + elif self.shuffled_playlist_current_index >= len(self.shuffled_playlist): + self.shuffled_playlist_current_index -= 1 + self.play(item_playlist_id=self.shuffled_playlist[self.shuffled_playlist_current_index]) self.stop() + else: + self.play(item_playlist_id=self.shuffled_playlist[self.shuffled_playlist_current_index]) + if not restore_playing: + self.stop() elif rem_idx_in_shuffled_playlist < self.shuffled_playlist_current_index: self.shuffled_playlist_current_index -= 1