Compare commits
2 Commits
2861511f1f
...
eae8870d4d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eae8870d4d | ||
|
|
93c5475a29 |
@ -114,6 +114,7 @@ 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
|
||||||
|
|||||||
@ -197,7 +197,6 @@ 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()
|
||||||
@ -1217,45 +1216,27 @@ 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
|
||||||
|
if not track_sequence.previous.resume_marker:
|
||||||
return
|
return
|
||||||
# TODO Reimplement without reference to playlist_tab
|
|
||||||
# # Return if no saved position
|
|
||||||
# if not self.previous_track_position:
|
|
||||||
# return
|
|
||||||
|
|
||||||
# # Note any playing track as this will become the next track
|
# We want to use play_next() to resume, so copy the previous
|
||||||
# playing_track = None
|
# track to the next track:
|
||||||
# if self.current_track.track_id:
|
track_sequence.next = track_sequence.previous
|
||||||
# playing_track = self.current_track
|
|
||||||
|
|
||||||
# # Set next plr to be track to resume
|
# Now resume playing the now-next track
|
||||||
# if not self.previous_track.plr_id:
|
self.play_next(track_sequence.next.resume_marker)
|
||||||
# return
|
|
||||||
# # TODO Reimplement following two lines
|
|
||||||
# # if not self.previous_track.playlist_tab:
|
|
||||||
# # return
|
|
||||||
|
|
||||||
# # Resume last track
|
# Adjust track info so that clocks and graph are correct.
|
||||||
# # TODO Reimplement next four lines
|
# We need to fake the start time to reflect where we resumed the
|
||||||
# # self.set_next_plr_id(
|
# track
|
||||||
# # self.previous_track.plr_id, self.previous_track.playlist_tab
|
if (
|
||||||
# # )
|
track_sequence.now.start_time
|
||||||
# # self.play_next(self.previous_track_position)
|
and track_sequence.now.duration
|
||||||
|
and track_sequence.now.resume_marker
|
||||||
# # Adjust track info so that clocks and graph are correct.
|
):
|
||||||
# # Easiest way is to fake the start time.
|
elapsed_ms = track_sequence.now.duration * track_sequence.now.resume_marker
|
||||||
# if self.current_track.start_time and self.current_track.duration:
|
track_sequence.now.start_time -= timedelta(milliseconds=elapsed_ms)
|
||||||
# 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"""
|
||||||
@ -1451,7 +1432,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Stop/fade track
|
# Stop/fade track
|
||||||
self.previous_track_position = self.music.get_position()
|
track_sequence.now.resume_marker = self.music.get_position()
|
||||||
if fade:
|
if fade:
|
||||||
self.music.fade()
|
self.music.fade()
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -448,6 +448,13 @@ 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
|
||||||
|
|||||||
@ -284,6 +284,20 @@ 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,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user