diff --git a/app/classes.py b/app/classes.py index aa2ed45..a943ede 100644 --- a/app/classes.py +++ b/app/classes.py @@ -797,4 +797,22 @@ class TrackSequence: current: Optional[RowAndTrack] = None previous: Optional[RowAndTrack] = None + def set_next(self, rat: Optional[RowAndTrack]) -> None: + """ + Set the 'next' track to be passed rat. Clear + any previous next track. If passed rat is None + just clear existing next track. + """ + + # Clear any existing fade graph + if self.next and self.next.fade_graph: + self.next.fade_graph.clear() + + if rat is None: + self.next = None + else: + self.next = rat + self.next.create_fade_graph() + + track_sequence = TrackSequence() diff --git a/app/musicmuster.py b/app/musicmuster.py index f86b194..a19cbdd 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -343,7 +343,7 @@ class Window(QMainWindow, Ui_MainWindow): Clear next track """ - track_sequence.next = None + track_sequence.set_next(None) self.update_headers() def clear_selection(self) -> None: @@ -1418,8 +1418,7 @@ class Window(QMainWindow, Ui_MainWindow): # We want to use play_next() to resume, so copy the previous # track to the next track: - track_sequence.next = track_sequence.previous - track_sequence.next.create_fade_graph() + track_sequence.set_next(track_sequence.previous) # Now resume playing the now-next track self.play_next(track_sequence.next.resume_marker) diff --git a/app/playlistmodel.py b/app/playlistmodel.py index 146151f..2f23971 100644 --- a/app/playlistmodel.py +++ b/app/playlistmodel.py @@ -1186,7 +1186,7 @@ class PlaylistModel(QAbstractTableModel): if row_number is None: # Clear next track if track_sequence.next is not None: - track_sequence.next = None + track_sequence.set_next(None) else: # Get playlistrow_id of row try: @@ -1205,8 +1205,7 @@ class PlaylistModel(QAbstractTableModel): if track_sequence.next: old_next_row = track_sequence.next.row_number - track_sequence.next = rat - track_sequence.next.create_fade_graph() + track_sequence.set_next(rat) self.invalidate_row(row_number) if Config.WIKIPEDIA_ON_NEXT: diff --git a/app/playlists.py b/app/playlists.py index 769f748..b94fd90 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -949,5 +949,6 @@ class PlaylistTab(QTableView): def _unmark_as_next(self) -> None: """Rescan track""" - self.source_model.set_next_row(None) + track_sequence.set_next(None) self.clear_selection() + self.signals.next_track_changed_signal.emit()