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)
|
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 (
|
if (
|
||||||
self.track_sequence.current
|
self.track_sequence.current
|
||||||
and self.track_sequence.current.playlist_id == self.playlist_id
|
and self.track_sequence.current.playlist_id == self.playlist_id
|
||||||
):
|
):
|
||||||
plr = self.track_sequence.current
|
plr = self.track_sequence.current
|
||||||
current_track_row_number = plr.row_number
|
current_track_row_number = plr.row_number
|
||||||
|
current_track_start_time = self.track_sequence.current.start_time
|
||||||
new_start_time = self.track_sequence.current.start_time
|
if current_track_start_time is None:
|
||||||
if not new_start_time:
|
|
||||||
raise ApplicationError(
|
raise ApplicationError(
|
||||||
f"Can't get start time for current track ({self.track_sequence.current=})"
|
f"Can't get start time for current track ({self.track_sequence.current=})"
|
||||||
)
|
)
|
||||||
|
current_track_end_time = self.get_end_time(
|
||||||
next_start_time = self.get_end_time(
|
current_track_row_number, current_track_start_time
|
||||||
current_track_row_number, new_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)
|
update_rows.append(current_track_row_number)
|
||||||
|
|
||||||
# If we have a next track, note row number
|
# If we have a next track, note row number
|
||||||
if (
|
if (
|
||||||
self.track_sequence.next
|
self.track_sequence.next
|
||||||
and self.track_sequence.next.playlist_id == self.playlist_id
|
and self.track_sequence.next.playlist_id == self.playlist_id
|
||||||
and next_start_time
|
|
||||||
):
|
):
|
||||||
next_track_row = self.track_sequence.next.row_number
|
next_track_row = self.track_sequence.next.row_number
|
||||||
|
|
||||||
@ -1566,10 +1563,12 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
for row_number in range(row_count):
|
for row_number in range(row_count):
|
||||||
plr = self.playlist_rows[row_number]
|
plr = self.playlist_rows[row_number]
|
||||||
|
|
||||||
# Don't update times for tracks that have been played, for
|
# Don't update times for tracks that have been played unless
|
||||||
# unreadable tracks or for the current track, handled above.
|
# this is the next track, for unreadable tracks or for the
|
||||||
|
# current track, handled above.
|
||||||
|
|
||||||
if (
|
if (
|
||||||
plr.played
|
(plr.played and row_number != next_track_row)
|
||||||
or row_number == current_track_row_number
|
or row_number == current_track_row_number
|
||||||
or (plr.path and file_is_unreadable(plr.path))
|
or (plr.path and file_is_unreadable(plr.path))
|
||||||
):
|
):
|
||||||
@ -1583,19 +1582,10 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Set start time for next row if we have a current track
|
# Set start time for next row if we have a current track
|
||||||
if current_track_row_number and row_number == next_track_row:
|
if current_track_row_number is not None and row_number == next_track_row:
|
||||||
plr = self.playlist_rows[row_number]
|
next_start_time = self.get_end_time(row_number, current_track_end_time)
|
||||||
this_start_time = self.playlist_rows[
|
if self.update_start_end_times(plr, current_track_end_time, next_start_time):
|
||||||
current_track_row_number
|
update_rows.append(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
|
|
||||||
):
|
|
||||||
update_rows.append(row_number)
|
|
||||||
|
|
||||||
# If we're between the current and next row, zero out
|
# If we're between the current and next row, zero out
|
||||||
# times
|
# times
|
||||||
@ -1608,9 +1598,11 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
update_rows.append(row_number)
|
update_rows.append(row_number)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Set start/end
|
# If we don't have a start time, keep looking
|
||||||
if not next_start_time:
|
if next_start_time is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Set start/end
|
||||||
plr = self.playlist_rows[row_number]
|
plr = self.playlist_rows[row_number]
|
||||||
start_time = next_start_time
|
start_time = next_start_time
|
||||||
next_start_time = self.get_end_time(row_number, next_start_time)
|
next_start_time = self.get_end_time(row_number, next_start_time)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user