fix playback bug

This commit is contained in:
Mark 2024-10-25 20:31:48 +02:00
parent 14660b6dae
commit c03c35f1c9

View File

@ -88,28 +88,25 @@ impl<T> PlayerBackend<T> for PlayerBackendPlaybackRs<T> {
} }
fn next(&mut self, play: bool, _load_duration: bool) { fn next(&mut self, play: bool, _load_duration: bool) {
self.pause(); self.pause();
self.player.stop();
self.player.skip(); self.player.skip();
self.current = self.next.take(); self.current = self.next.take();
if self.player.has_current_song() { if let Some((id, song, _)) = &self.current {
self.player.set_playing(play); if let Some(song) = song {
} else { if let Err(e) = self.player.play_song_now(song, None) {
if let Some((id, song, _)) = &self.current { if let Some(s) = &self.command_sender {
if let Some(song) = song { s.send(Command::ErrorInfo(
if let Err(e) = self.player.play_song_now(song, None) { format!("Couldn't play song #{id}!"),
if let Some(s) = &self.command_sender { format!("Error: {e}"),
s.send(Command::ErrorInfo( ))
format!("Couldn't play song #{id}!"), .unwrap();
format!("Error: {e}"), s.send(Command::NextSong).unwrap();
))
.unwrap();
s.send(Command::NextSong).unwrap();
}
} else {
self.player.set_playing(play);
} }
} else if let Some(s) = &self.command_sender { } else {
s.send(Command::NextSong).unwrap(); self.player.set_playing(play);
} }
} else if let Some(s) = &self.command_sender {
s.send(Command::NextSong).unwrap();
} }
} }
} }