diff --git a/wobuzz/gui_communication/gui_communication.py b/wobuzz/gui_communication/gui_communication.py index 37f767f..59d68b6 100644 --- a/wobuzz/gui_communication/gui_communication.py +++ b/wobuzz/gui_communication/gui_communication.py @@ -22,6 +22,9 @@ class GUICommunication: def on_track_start(self): self.track_control.on_track_start() + def on_playstate_update(self): + self.track_control.on_playstate_update() + def on_settings_change(self, key, value): self.settings.update_settings(key, value) diff --git a/wobuzz/gui_communication/track_control.py b/wobuzz/gui_communication/track_control.py index 79995d7..d66a24f 100644 --- a/wobuzz/gui_communication/track_control.py +++ b/wobuzz/gui_communication/track_control.py @@ -43,7 +43,6 @@ class TrackControl: def stop(self): if self.app.player.current_playlist.has_tracks(): self.app.player.stop() - self.track_control.toggle_play_button.setIcon(self.play_icon) def next_track(self): if self.app.player.current_playlist.has_tracks(): @@ -90,13 +89,22 @@ class TrackControl: def toggle_playing(self): if self.app.player.playing and self.app.player.paused: # paused self.app.player.unpause() - self.track_control.toggle_play_button.setIcon(self.pause_icon) elif self.app.player.playing: # playing self.app.player.pause() - self.track_control.toggle_play_button.setIcon(self.play_icon) elif self.app.player.current_playlist.has_tracks(): # stopped but tracks in the current playlist self.app.player.start_playing() - self.track_control.toggle_play_button.setIcon(self.pause_icon) + + def on_playstate_update(self): + if self.app.player.playing: + if self.app.player.paused: + self.track_control.toggle_play_button.setIcon(self.play_icon) + + else: + self.track_control.toggle_play_button.setIcon(self.pause_icon) + + else: + self.track_control.toggle_play_button.setIcon(self.play_icon) + diff --git a/wobuzz/player/player.py b/wobuzz/player/player.py index f433815..f12a71a 100644 --- a/wobuzz/player/player.py +++ b/wobuzz/player/player.py @@ -33,6 +33,8 @@ class Player: self.playing = True self.paused = False + self.app.gui_communication.on_playstate_update() + def track_finished(self): if not self.current_playlist.on_last_track(): self.current_sound, self.current_sound_duration = self.current_playlist.next_track() @@ -51,6 +53,7 @@ class Player: self.play() self.track_progress.start() self.app.gui_communication.on_track_start() + self.app.gui_communication.on_playstate_update() def play_track_in_playlist(self, track_index): self.stop() @@ -66,6 +69,8 @@ class Player: self.track_progress.pause() self.paused = True + self.app.gui_communication.on_playstate_update() + def unpause(self): self.music_channel.unpause() self.track_progress.unpause() @@ -73,6 +78,8 @@ class Player: self.playing = True self.paused = False + self.app.gui_communication.on_playstate_update() + def next_track(self): if not self.current_playlist.on_last_track(): self.music_channel.stop() @@ -100,6 +107,8 @@ class Player: self.playing = False self.paused = False + self.app.gui_communication.on_playstate_update() + def seek(self, position: int): self.music_channel.stop() self.track_progress.stop()