mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Tweak malformed gid handling
This commit is contained in:
parent
c0416972b6
commit
b0ee8ec74d
1 changed files with 10 additions and 15 deletions
|
@ -794,30 +794,25 @@ impl SpircTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_track(&mut self, play: bool) {
|
fn load_track(&mut self, play: bool) {
|
||||||
let mut index = self.state.get_playing_track_index();
|
|
||||||
let track = {
|
let track = {
|
||||||
// let gid = self.state.get_track()[index as usize].get_gid();
|
let mut index = self.state.get_playing_track_index();
|
||||||
let track_ref = self.state.get_track()[index as usize].to_owned();
|
// Check for malformed gid
|
||||||
let mut gid = track_ref.get_gid();
|
let tracks_len = self.state.get_track().len() as u32;
|
||||||
if gid.len() != 16 {
|
let mut track_ref = &self.state.get_track()[index as usize];
|
||||||
let track_len = self.state.get_track().len() as u32;
|
while track_ref.get_gid().len() != 16 {
|
||||||
if index < track_len - 1 {
|
|
||||||
index = 0;
|
|
||||||
} else {
|
|
||||||
index = index + 1;
|
|
||||||
}
|
|
||||||
warn!(
|
warn!(
|
||||||
"Skipping track {:?} at position [{}] of {}",
|
"Skipping track {:?} at position [{}] of {}",
|
||||||
track_ref.get_uri(),
|
track_ref.get_uri(),
|
||||||
index,
|
index,
|
||||||
track_len
|
tracks_len
|
||||||
);
|
);
|
||||||
gid = self.state.get_track()[index as usize].get_gid();
|
index = if index + 1 < tracks_len { index + 1 } else { 0 };
|
||||||
|
track_ref = &self.state.get_track()[index as usize];
|
||||||
}
|
}
|
||||||
SpotifyId::from_raw(gid).unwrap()
|
SpotifyId::from_raw(track_ref.get_gid()).unwrap()
|
||||||
};
|
};
|
||||||
let position = self.state.get_position_ms();
|
|
||||||
|
|
||||||
|
let position = self.state.get_position_ms();
|
||||||
let end_of_track = self.player.load(track, play, position);
|
let end_of_track = self.player.load(track, play, position);
|
||||||
|
|
||||||
if play {
|
if play {
|
||||||
|
|
Loading…
Reference in a new issue