mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Fix out of bounds panic
Selecting a librespot device with the Spotify desktop client causes a crash if the playlist is empty. Take into account the case where an empty list of tracks is received. In this case notify the desktop client, so it will accept the device and turn the status bar green. Closes: #71
This commit is contained in:
parent
cf7378fda4
commit
0716643ae3
1 changed files with 8 additions and 5 deletions
|
@ -209,11 +209,14 @@ impl SpircInternal {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.reload_tracks(&frame);
|
self.reload_tracks(&frame);
|
||||||
|
if self.tracks.len() > 0 {
|
||||||
let play = frame.get_state().get_status() == PlayStatus::kPlayStatusPlay;
|
let play = frame.get_state().get_status() == PlayStatus::kPlayStatusPlay;
|
||||||
let track = self.tracks[self.index as usize];
|
let track = self.tracks[self.index as usize];
|
||||||
let position = frame.get_state().get_position_ms();
|
let position = frame.get_state().get_position_ms();
|
||||||
self.player.load(track, play, position);
|
self.player.load(track, play, position);
|
||||||
|
} else {
|
||||||
|
self.notify(false, Some(frame.get_ident()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MessageType::kMessageTypePlay => {
|
MessageType::kMessageTypePlay => {
|
||||||
self.player.play();
|
self.player.play();
|
||||||
|
|
Loading…
Reference in a new issue