forked from Wobbl/Wobuzz
Added history and improved marking of playing track.
This commit is contained in:
parent
29f86e2196
commit
74bff6ea13
3 changed files with 48 additions and 14 deletions
|
@ -18,6 +18,7 @@ class Player:
|
|||
self.track_progress = TrackProgress(self.app)
|
||||
|
||||
self.current_playlist = Playlist(self.app, "None")
|
||||
self.history = Playlist(self.app, "History")
|
||||
|
||||
self.playing = False
|
||||
self.paused = False
|
||||
|
@ -38,15 +39,19 @@ class Player:
|
|||
|
||||
def track_finished(self):
|
||||
if not self.current_playlist.on_last_track():
|
||||
previous_track = self.current_playlist.current_track
|
||||
self.current_sound, self.current_sound_duration = self.current_playlist.next_track()
|
||||
|
||||
self.play()
|
||||
self.track_progress.start()
|
||||
self.app.gui.on_track_change(previous_track, self.current_playlist.current_track)
|
||||
|
||||
self.history.append_track(self.current_playlist.current_track)
|
||||
|
||||
last_track = self.history.h_last_track()
|
||||
|
||||
self.app.gui.on_track_change(last_track, self.current_playlist.current_track)
|
||||
|
||||
if self.app.settings.clear_track_cache:
|
||||
previous_track.clear_cache()
|
||||
last_track.clear_cache()
|
||||
|
||||
else:
|
||||
self.stop()
|
||||
|
@ -58,6 +63,8 @@ class Player:
|
|||
self.play()
|
||||
self.track_progress.start()
|
||||
|
||||
self.history.append_track(self.current_playlist.current_track)
|
||||
|
||||
self.app.gui.on_track_change(None, self.current_playlist.current_track)
|
||||
|
||||
self.app.gui.track_control.on_playstate_update()
|
||||
|
@ -65,16 +72,26 @@ class Player:
|
|||
def play_track_in_playlist(self, track_index):
|
||||
self.stop()
|
||||
|
||||
previous_track = self.current_playlist.current_track
|
||||
if len(self.history.tracks) == 0:
|
||||
self.history.append_track(self.current_playlist.current_track)
|
||||
|
||||
self.current_sound, self.current_sound_duration = self.current_playlist.set_track(track_index)
|
||||
|
||||
self.play()
|
||||
self.track_progress.start()
|
||||
self.app.gui.on_track_change(previous_track, self.current_playlist.current_track)
|
||||
|
||||
if self.app.settings.clear_track_cache and not previous_track == self.current_playlist.current_track:
|
||||
previous_track.clear_cache()
|
||||
self.history.append_track(self.current_playlist.current_track)
|
||||
|
||||
last_track = self.history.h_last_track()
|
||||
|
||||
self.app.gui.on_track_change(last_track, self.current_playlist.current_track)
|
||||
|
||||
if (
|
||||
self.app.settings.clear_track_cache and
|
||||
not last_track is None and
|
||||
not last_track == self.current_playlist.current_track
|
||||
):
|
||||
last_track.clear_cache()
|
||||
|
||||
def pause(self):
|
||||
self.music_channel.pause()
|
||||
|
@ -102,8 +119,6 @@ class Player:
|
|||
if not self.current_playlist.on_first_track():
|
||||
self.music_channel.stop()
|
||||
|
||||
last_track = self.current_playlist.current_track
|
||||
|
||||
self.current_sound, self.current_sound_duration = self.current_playlist.previous_track()
|
||||
|
||||
self.track_progress.stop()
|
||||
|
@ -111,7 +126,9 @@ class Player:
|
|||
self.play()
|
||||
self.track_progress.start()
|
||||
|
||||
self.app.gui.on_track_change(last_track, self.current_playlist.current_track)
|
||||
self.history.append_track(self.current_playlist.current_track)
|
||||
|
||||
self.app.gui.on_track_change(self.history.h_last_track(), self.current_playlist.current_track)
|
||||
|
||||
def stop(self):
|
||||
self.music_channel.stop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue