mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Fix bugs in player
This commit is contained in:
parent
1f40affe1f
commit
2f05ddfbc2
1 changed files with 14 additions and 17 deletions
|
@ -327,15 +327,12 @@ impl Player {
|
|||
}
|
||||
|
||||
pub async fn get_end_of_track_future(&self) {
|
||||
self.get_player_event_channel()
|
||||
.filter(|event| {
|
||||
future::ready(matches!(
|
||||
event,
|
||||
PlayerEvent::EndOfTrack { .. } | PlayerEvent::Stopped { .. }
|
||||
))
|
||||
})
|
||||
.for_each(|_| future::ready(()))
|
||||
.await
|
||||
let mut channel = self.get_player_event_channel();
|
||||
while let Some(event) = channel.next().await {
|
||||
if matches!(event, PlayerEvent::EndOfTrack { .. } | PlayerEvent::Stopped { .. }) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_sink_event_callback(&self, callback: Option<SinkEventCallback>) {
|
||||
|
@ -676,14 +673,6 @@ impl PlayerTrackLoader {
|
|||
let bytes_per_second = self.stream_data_rate(format);
|
||||
let play_from_beginning = position_ms == 0;
|
||||
|
||||
let key = match self.session.audio_key().request(spotify_id, file_id).await {
|
||||
Ok(key) => key,
|
||||
Err(_) => {
|
||||
error!("Unable to load decryption key");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
// This is only a loop to be able to reload the file if an error occured
|
||||
// while opening a cached file.
|
||||
loop {
|
||||
|
@ -712,6 +701,14 @@ impl PlayerTrackLoader {
|
|||
// we need to seek -> we set stream mode after the initial seek.
|
||||
stream_loader_controller.set_random_access_mode();
|
||||
}
|
||||
|
||||
let key = match self.session.audio_key().request(spotify_id, file_id).await {
|
||||
Ok(key) => key,
|
||||
Err(_) => {
|
||||
error!("Unable to load decryption key");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
let mut decrypted_file = AudioDecrypt::new(key, encrypted_file);
|
||||
|
||||
|
|
Loading…
Reference in a new issue