Improved icon changing of play/pause button.
This commit is contained in:
parent
44854af42f
commit
29cc80feae
3 changed files with 24 additions and 4 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue