Slightly simplify track times; appears to be working
This commit is contained in:
parent
c93d24aef5
commit
25771f5235
@ -1533,32 +1533,29 @@ class PlaylistModel(QAbstractTableModel):
|
||||
|
||||
row_count = len(self.playlist_rows)
|
||||
|
||||
# If we have a current track, use its start time
|
||||
# If we have a current track, get its end time
|
||||
if (
|
||||
self.track_sequence.current
|
||||
and self.track_sequence.current.playlist_id == self.playlist_id
|
||||
):
|
||||
plr = self.track_sequence.current
|
||||
current_track_row_number = plr.row_number
|
||||
|
||||
new_start_time = self.track_sequence.current.start_time
|
||||
if not new_start_time:
|
||||
current_track_start_time = self.track_sequence.current.start_time
|
||||
if current_track_start_time is None:
|
||||
raise ApplicationError(
|
||||
f"Can't get start time for current track ({self.track_sequence.current=})"
|
||||
)
|
||||
|
||||
next_start_time = self.get_end_time(
|
||||
current_track_row_number, new_start_time
|
||||
current_track_end_time = self.get_end_time(
|
||||
current_track_row_number, current_track_start_time
|
||||
)
|
||||
|
||||
if self.update_start_end_times(plr, new_start_time, next_start_time):
|
||||
if self.update_start_end_times(plr, current_track_start_time, current_track_end_time):
|
||||
update_rows.append(current_track_row_number)
|
||||
|
||||
# If we have a next track, note row number
|
||||
if (
|
||||
self.track_sequence.next
|
||||
and self.track_sequence.next.playlist_id == self.playlist_id
|
||||
and next_start_time
|
||||
):
|
||||
next_track_row = self.track_sequence.next.row_number
|
||||
|
||||
@ -1566,10 +1563,12 @@ class PlaylistModel(QAbstractTableModel):
|
||||
for row_number in range(row_count):
|
||||
plr = self.playlist_rows[row_number]
|
||||
|
||||
# Don't update times for tracks that have been played, for
|
||||
# unreadable tracks or for the current track, handled above.
|
||||
# Don't update times for tracks that have been played unless
|
||||
# this is the next track, for unreadable tracks or for the
|
||||
# current track, handled above.
|
||||
|
||||
if (
|
||||
plr.played
|
||||
(plr.played and row_number != next_track_row)
|
||||
or row_number == current_track_row_number
|
||||
or (plr.path and file_is_unreadable(plr.path))
|
||||
):
|
||||
@ -1583,18 +1582,9 @@ class PlaylistModel(QAbstractTableModel):
|
||||
continue
|
||||
|
||||
# Set start time for next row if we have a current track
|
||||
if current_track_row_number and row_number == next_track_row:
|
||||
plr = self.playlist_rows[row_number]
|
||||
this_start_time = self.playlist_rows[
|
||||
current_track_row_number
|
||||
].forecast_end_time
|
||||
if this_start_time:
|
||||
next_start_time = self.get_end_time(
|
||||
current_track_row_number, this_start_time
|
||||
)
|
||||
if self.update_start_end_times(
|
||||
plr, this_start_time, next_start_time
|
||||
):
|
||||
if current_track_row_number is not None and row_number == next_track_row:
|
||||
next_start_time = self.get_end_time(row_number, current_track_end_time)
|
||||
if self.update_start_end_times(plr, current_track_end_time, next_start_time):
|
||||
update_rows.append(row_number)
|
||||
|
||||
# If we're between the current and next row, zero out
|
||||
@ -1608,9 +1598,11 @@ class PlaylistModel(QAbstractTableModel):
|
||||
update_rows.append(row_number)
|
||||
continue
|
||||
|
||||
# Set start/end
|
||||
if not next_start_time:
|
||||
# If we don't have a start time, keep looking
|
||||
if next_start_time is None:
|
||||
continue
|
||||
|
||||
# Set start/end
|
||||
plr = self.playlist_rows[row_number]
|
||||
start_time = next_start_time
|
||||
next_start_time = self.get_end_time(row_number, next_start_time)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user