Skip to content

Commit

Permalink
fixed crash when removing last item from playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
m1lhaus committed Aug 20, 2016
1 parent e3ee141 commit 96e2cc1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions components/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 96e2cc1

Please sign in to comment.