Handle unplayable track at start of playlist

This commit is contained in:
ashthespy 2020-05-27 16:24:21 +02:00
parent 01813cf7c9
commit 1da80ce480

View file

@ -910,13 +910,17 @@ impl SpircTask {
| SpircPlayStatus::Stopped => (), | SpircPlayStatus::Stopped => (),
} }
} }
// Mark unavailable tracks so we can skip them later // Mark unavailable tracks so we can skip them later
fn handle_unavailable(&mut self, track_id: SpotifyId) { fn handle_unavailable(&mut self, track_id: SpotifyId) {
let unavailables = self.get_track_index_for_spotify_id( let playing_index = self.state.get_playing_track_index() as usize;
&track_id, let search_from = if playing_index == self.state.get_track().len() - 1 {
self.state.get_playing_track_index() as usize, trace!("Cycling back to 0 instead of {:?}", playing_index);
); 0
} else {
playing_index
};
let unavailables = self.get_track_index_for_spotify_id(&track_id, search_from);
for &index in unavailables.iter() { for &index in unavailables.iter() {
debug_assert_eq!(self.state.get_track()[index].get_gid(), track_id.to_raw()); debug_assert_eq!(self.state.get_track()[index].get_gid(), track_id.to_raw());
let mut unplayable_track_ref = TrackRef::new(); let mut unplayable_track_ref = TrackRef::new();