Compare commits

..

No commits in common. "eae8870d4d154253e54bb73a252bd2ecfd7aff86" and "2861511f1fcd58f90191f579f3459a301942a1e3" have entirely different histories.

4 changed files with 38 additions and 41 deletions

View File

@ -114,7 +114,6 @@ class PlaylistTrack:
self.playlist_id: Optional[int] = None self.playlist_id: Optional[int] = None
self.plr_id: Optional[int] = None self.plr_id: Optional[int] = None
self.plr_rownum: Optional[int] = None self.plr_rownum: Optional[int] = None
self.resume_marker: Optional[float] = None
self.silence_at: Optional[int] = None self.silence_at: Optional[int] = None
self.start_gap: Optional[int] = None self.start_gap: Optional[int] = None
self.start_time: Optional[datetime] = None self.start_time: Optional[datetime] = None

View File

@ -197,6 +197,7 @@ class Window(QMainWindow, Ui_MainWindow):
self.music: music.Music = music.Music() self.music: music.Music = music.Music()
self.playing: bool = False self.playing: bool = False
self.previous_track_position: Optional[float] = None
self.selected_plrs: Optional[List[PlaylistRows]] = None self.selected_plrs: Optional[List[PlaylistRows]] = None
self.set_main_window_size() self.set_main_window_size()
@ -1216,27 +1217,45 @@ class Window(QMainWindow, Ui_MainWindow):
- If a track is playing, make that the next track - If a track is playing, make that the next track
""" """
# Return if no saved position return
if not track_sequence.previous.resume_marker: # TODO Reimplement without reference to playlist_tab
return # # Return if no saved position
# if not self.previous_track_position:
# return
# We want to use play_next() to resume, so copy the previous # # Note any playing track as this will become the next track
# track to the next track: # playing_track = None
track_sequence.next = track_sequence.previous # if self.current_track.track_id:
# playing_track = self.current_track
# Now resume playing the now-next track # # Set next plr to be track to resume
self.play_next(track_sequence.next.resume_marker) # if not self.previous_track.plr_id:
# return
# # TODO Reimplement following two lines
# # if not self.previous_track.playlist_tab:
# # return
# Adjust track info so that clocks and graph are correct. # # Resume last track
# We need to fake the start time to reflect where we resumed the # # TODO Reimplement next four lines
# track # # self.set_next_plr_id(
if ( # # self.previous_track.plr_id, self.previous_track.playlist_tab
track_sequence.now.start_time # # )
and track_sequence.now.duration # # self.play_next(self.previous_track_position)
and track_sequence.now.resume_marker
): # # Adjust track info so that clocks and graph are correct.
elapsed_ms = track_sequence.now.duration * track_sequence.now.resume_marker # # Easiest way is to fake the start time.
track_sequence.now.start_time -= timedelta(milliseconds=elapsed_ms) # if self.current_track.start_time and self.current_track.duration:
# elapsed_ms = self.current_track.duration * self.previous_track_position
# self.current_track.start_time -= timedelta(milliseconds=elapsed_ms)
# # If a track was playing when we were called, get details to
# # set it as the next track
# if playing_track:
# if not playing_track.plr_id:
# return
# if not playing_track.playlist_tab:
# return
# self.set_next_plr_id(playing_track.plr_id, playing_track.playlist_tab)
def save_as_template(self) -> None: def save_as_template(self) -> None:
"""Save current playlist as template""" """Save current playlist as template"""
@ -1432,7 +1451,7 @@ class Window(QMainWindow, Ui_MainWindow):
return return
# Stop/fade track # Stop/fade track
track_sequence.now.resume_marker = self.music.get_position() self.previous_track_position = self.music.get_position()
if fade: if fade:
self.music.fade() self.music.fade()
else: else:

View File

@ -448,13 +448,6 @@ class PlaylistModel(QAbstractTableModel):
return QVariant(boldfont) return QVariant(boldfont)
def get_row_track_path(self, row_number: int) -> str:
"""
Return path of track associated with row or empty string if no track associated
"""
return self.playlist_rows[row_number].path
def get_rows_duration(self, row_numbers: List[int]) -> int: def get_rows_duration(self, row_numbers: List[int]) -> int:
""" """
Return the total duration of the passed rows Return the total duration of the passed rows

View File

@ -284,20 +284,6 @@ class PlaylistTab(QTableView):
return index.row() return index.row()
return None return None
def get_selected_row_track_path(self) -> str:
"""
Return the path of the selected row. If no row selected or selected
row does not have a track, return empty string.
"""
sm = self.selectionModel()
if sm and sm.hasSelection():
index = sm.currentIndex()
if index.isValid():
model = cast(PlaylistModel, self.model())
return model.get_row_track_path(index.row())
return ""
# def lookup_row_in_songfacts(self) -> None: # def lookup_row_in_songfacts(self) -> None:
# """ # """
# If there is a selected row and it is a track row, # If there is a selected row and it is a track row,