Improve metadata handling; fixes #20

This commit is contained in:
Keith Edmunds 2021-06-12 10:09:32 +01:00
parent f4efeac36a
commit f37c6f3e70
2 changed files with 28 additions and 17 deletions

View File

@ -59,7 +59,7 @@ class Music:
p = self.player
self.player = None
DEBUG(f"music._fade() post-lock, {self.player=}", True)
DEBUG("music._fade() post-lock", True)
fade_time = Config.FADE_TIME / 1000
steps = Config.FADE_STEPS

View File

@ -219,6 +219,23 @@ class Window(QMainWindow, Ui_MainWindow):
self.actionPlay_next.setEnabled(True)
self.statusbar.showMessage("Play controls: Enabled", 0)
def end_of_track_actions(self):
"Clean up after track played"
# Clean up metadata
self.previous_track = self.current_track
self.current_track_playlist_tab.play_stopped()
self.current_track_playlist_tab.clear_current()
self.current_track_playlist_tab = None
self.current_track = None
self.playing = False
# Clean up display
self.label_end_timer.setText("00:00")
self.frame_silent.setStyleSheet("")
self.frame_fade.setStyleSheet("")
self.update_headers()
def export_playlist_tab(self):
"Export the current playlist to an m3u file"
@ -260,12 +277,17 @@ class Window(QMainWindow, Ui_MainWindow):
def fade(self):
"Fade currently playing track"
DEBUG("musicmuster:fade()", True)
if not self.current_track:
return
# Set self.playing to False so that tick() doesn't see
# player=None and kick off end-of-track actions
self.playing = False
self.enable_play_next_controls()
self.previous_track = self.current_track
self.previous_track_position = self.music.fade()
self.end_of_track_actions()
def insert_note(self):
"Add non-track row to playlist"
@ -525,11 +547,11 @@ class Window(QMainWindow, Ui_MainWindow):
else:
self.music.stop()
DEBUG("musicmuster.stop_playing(): stopping music", True)
self.current_track_playlist_tab.clear_current()
# Shuffle tracks along
self.previous_track = self.current_track
self.end_of_track_actions()
# Release player
self.music.stop()
self.update_headers()
def test_function(self):
@ -619,18 +641,7 @@ class Window(QMainWindow, Ui_MainWindow):
else:
if self.playing:
self.label_end_timer.setText("00:00")
self.frame_silent.setStyleSheet("")
self.frame_fade.setStyleSheet("")
self.current_track_playlist_tab.play_stopped()
self.playing = False
self.previous_track = self.current_track
self.current_track = None
self.current_track_playlist_tab = None
self.previous_track_position = 0
self.update_headers()
# Release player
self.music.stop()
self.stop_playing()
def update_headers(self):
"Update last / current / next track headers"