Allow broken file playback

This commit is contained in:
Jan-Henrik 2024-03-18 20:34:07 +01:00
parent b862d08167
commit aa3518807a
2 changed files with 7 additions and 10 deletions

View file

@ -1,4 +1,3 @@
use awedio::Sound;
use bytes::Buf;
use serde::Deserialize;

View file

@ -95,17 +95,15 @@ impl Sound for Player {
self.was_empty = false;
return Ok(NextSample::MetadataChanged);
}
let next_sample = match next_sound.next_sample() {
Ok(s) => s,
Err(e) => {
self.sounds.remove(0);
return Err(e);
}
};
let next_sample = next_sound.next_sample();
if let Err(e) = &next_sample {
println!("Error playing track: {:?}", e);
}
let ret = match next_sample {
NextSample::Sample(_) | NextSample::MetadataChanged | NextSample::Paused => next_sample,
NextSample::Finished => {
Ok(NextSample::Sample(_) | NextSample::MetadataChanged | NextSample::Paused) => next_sample.unwrap(),
Ok(NextSample::Finished) | Err(_) => { // Just ignore the error
self.sounds.remove(0);
if self.sounds.is_empty() {
NextSample::Finished