mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Prevent shuffle crash
fixes https://github.com/librespot-org/librespot/issues/959
This commit is contained in:
parent
f4be9bb85d
commit
edb98d5c1d
1 changed files with 3 additions and 3 deletions
|
@ -668,15 +668,15 @@ impl SpircTask {
|
||||||
self.state.set_shuffle(frame.get_state().get_shuffle());
|
self.state.set_shuffle(frame.get_state().get_shuffle());
|
||||||
if self.state.get_shuffle() {
|
if self.state.get_shuffle() {
|
||||||
let current_index = self.state.get_playing_track_index();
|
let current_index = self.state.get_playing_track_index();
|
||||||
{
|
|
||||||
let tracks = self.state.mut_track();
|
let tracks = self.state.mut_track();
|
||||||
|
if !tracks.is_empty() {
|
||||||
tracks.swap(0, current_index as usize);
|
tracks.swap(0, current_index as usize);
|
||||||
if let Some((_, rest)) = tracks.split_first_mut() {
|
if let Some((_, rest)) = tracks.split_first_mut() {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
rest.shuffle(&mut rng);
|
rest.shuffle(&mut rng);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
self.state.set_playing_track_index(0);
|
self.state.set_playing_track_index(0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let context = self.state.get_context_uri();
|
let context = self.state.get_context_uri();
|
||||||
debug!("{:?}", context);
|
debug!("{:?}", context);
|
||||||
|
|
Loading…
Reference in a new issue