mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Skip unplayable tracks instead of stopping
This commit is contained in:
parent
7670ffe101
commit
b63199743a
1 changed files with 63 additions and 2 deletions
|
@ -378,6 +378,7 @@ impl PlayerState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn is_stopped(&self) -> bool {
|
fn is_stopped(&self) -> bool {
|
||||||
use self::PlayerState::*;
|
use self::PlayerState::*;
|
||||||
match *self {
|
match *self {
|
||||||
|
@ -386,6 +387,14 @@ impl PlayerState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_loading(&self) -> bool {
|
||||||
|
use self::PlayerState::*;
|
||||||
|
match *self {
|
||||||
|
Loading { .. } => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn decoder(&mut self) -> Option<&mut Decoder> {
|
fn decoder(&mut self) -> Option<&mut Decoder> {
|
||||||
use self::PlayerState::*;
|
use self::PlayerState::*;
|
||||||
match *self {
|
match *self {
|
||||||
|
@ -728,8 +737,14 @@ impl Future for PlayerInternal {
|
||||||
}
|
}
|
||||||
Ok(Async::NotReady) => (),
|
Ok(Async::NotReady) => (),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
self.handle_player_stop();
|
warn!("Unable to load <{:?}>", track_id);
|
||||||
assert!(self.state.is_stopped());
|
warn!("Skipping to next track");
|
||||||
|
trace!("State: {:?}", self.state);
|
||||||
|
assert!(self.state.is_loading());
|
||||||
|
self.send_event(PlayerEvent::EndOfTrack {
|
||||||
|
track_id,
|
||||||
|
play_request_id,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -749,6 +764,7 @@ impl Future for PlayerInternal {
|
||||||
}
|
}
|
||||||
Ok(Async::NotReady) => (),
|
Ok(Async::NotReady) => (),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
warn!("Unable to preload {:?}", track_id);
|
||||||
self.preload = PlayerPreload::None;
|
self.preload = PlayerPreload::None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1523,6 +1539,51 @@ impl ::std::fmt::Debug for PlayerCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ::std::fmt::Debug for PlayerState {
|
||||||
|
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
|
use PlayerState::*;
|
||||||
|
match *self {
|
||||||
|
Stopped => f.debug_struct("Stopped").finish(),
|
||||||
|
Loading {
|
||||||
|
track_id,
|
||||||
|
play_request_id,
|
||||||
|
..
|
||||||
|
} => f
|
||||||
|
.debug_struct("Loading")
|
||||||
|
.field("track_id", &track_id)
|
||||||
|
.field("play_request_id", &play_request_id)
|
||||||
|
.finish(),
|
||||||
|
Paused {
|
||||||
|
track_id,
|
||||||
|
play_request_id,
|
||||||
|
..
|
||||||
|
} => f
|
||||||
|
.debug_struct("Paused")
|
||||||
|
.field("track_id", &track_id)
|
||||||
|
.field("play_request_id", &play_request_id)
|
||||||
|
.finish(),
|
||||||
|
Playing {
|
||||||
|
track_id,
|
||||||
|
play_request_id,
|
||||||
|
..
|
||||||
|
} => f
|
||||||
|
.debug_struct("Playing")
|
||||||
|
.field("track_id", &track_id)
|
||||||
|
.field("play_request_id", &play_request_id)
|
||||||
|
.finish(),
|
||||||
|
EndOfTrack {
|
||||||
|
track_id,
|
||||||
|
play_request_id,
|
||||||
|
..
|
||||||
|
} => f
|
||||||
|
.debug_struct("EndOfTrack")
|
||||||
|
.field("track_id", &track_id)
|
||||||
|
.field("play_request_id", &play_request_id)
|
||||||
|
.finish(),
|
||||||
|
Invalid => f.debug_struct("Invalid").finish(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
struct Subfile<T: Read + Seek> {
|
struct Subfile<T: Read + Seek> {
|
||||||
stream: T,
|
stream: T,
|
||||||
offset: u64,
|
offset: u64,
|
||||||
|
|
Loading…
Reference in a new issue