Skip over unreadable tracks when selecting next track.

This commit is contained in:
Keith Edmunds 2023-01-01 11:08:37 +00:00
parent 5e75659c48
commit 4edcab1542

View File

@ -1284,7 +1284,12 @@ class PlaylistTab(QTableWidget):
session, self.playlist_id) session, self.playlist_id)
] ]
for row in range(starting_row, self.rowCount()): for row in range(starting_row, self.rowCount()):
if row not in track_rows or row in played_rows: plr = self._get_playlistrow_object(session, row)
if (
row not in track_rows or
row in played_rows or
not file_is_readable(plr.track.path)
):
continue continue
else: else:
return row return row
@ -1325,6 +1330,12 @@ class PlaylistTab(QTableWidget):
return playlistrow_id return playlistrow_id
def _get_playlistrow_object(self, session: Session, row: int) -> int:
"""Return the playlistrow object associated with this row"""
playlistrow_id = (self.item(row, USERDATA).data(self.PLAYLISTROW_ID))
return session.get(PlaylistRows, playlistrow_id)
def _get_row_artist(self, row: int) -> Optional[str]: def _get_row_artist(self, row: int) -> Optional[str]:
"""Return artist on this row or None if none""" """Return artist on this row or None if none"""
@ -1755,7 +1766,6 @@ class PlaylistTab(QTableWidget):
# Check track is readable # Check track is readable
if not file_is_readable(track.path): if not file_is_readable(track.path):
self._set_unreadable_row(row_number)
return None return None
# Notify musicmuster # Notify musicmuster
@ -1763,6 +1773,7 @@ class PlaylistTab(QTableWidget):
self.musicmuster.this_is_the_next_playlist_row(session, plr, self) self.musicmuster.this_is_the_next_playlist_row(session, plr, self)
# Update display # Update display
self.clear_selection()
self.update_display(session) self.update_display(session)
def _set_played_row(self, session: Session, row: int) -> None: def _set_played_row(self, session: Session, row: int) -> None: