diff --git a/wobuzz/player/player.py b/wobuzz/player/player.py index 824f95a..5400780 100644 --- a/wobuzz/player/player.py +++ b/wobuzz/player/player.py @@ -56,13 +56,18 @@ class Player: def track_finished(self): self.current_playlist_index += 1 - self.playing_track = self.current_playlist[self.current_playlist_index] - self.playing_segment = self.playing_track.sound - self.playing_segment_duration = self.playing_track.duration + if self.current_playlist_index < len(self.current_playlist): + self.playing_track = self.current_playlist[self.current_playlist_index] + self.playing_segment = self.playing_track.sound + self.playing_segment_duration = self.playing_track.duration - self.music_channel.play(self.playing_track.sound) - self.track_progress.start() - self.app.gui_communication.on_track_start() + self.music_channel.play(self.playing_track.sound) + self.track_progress.start() + self.app.gui_communication.on_track_start() + + else: + self.current_playlist_index -= 1 + self.stop() def start_playing(self): self.music_channel.play(self.playing_track.sound) @@ -114,6 +119,7 @@ class Player: self.music_channel.stop() self.track_progress.stop() self.playing = False + self.playing_segment_duration = self.playing_track.duration def seek(self, position: int): self.searched = True