mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-05 10:49:40 +02: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) {
|
pub async fn get_end_of_track_future(&self) {
|
||||||
self.get_player_event_channel()
|
let mut channel = self.get_player_event_channel();
|
||||||
.filter(|event| {
|
while let Some(event) = channel.next().await {
|
||||||
future::ready(matches!(
|
if matches!(event, PlayerEvent::EndOfTrack { .. } | PlayerEvent::Stopped { .. }) {
|
||||||
event,
|
return;
|
||||||
PlayerEvent::EndOfTrack { .. } | PlayerEvent::Stopped { .. }
|
}
|
||||||
))
|
}
|
||||||
})
|
|
||||||
.for_each(|_| future::ready(()))
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_sink_event_callback(&self, callback: Option<SinkEventCallback>) {
|
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 bytes_per_second = self.stream_data_rate(format);
|
||||||
let play_from_beginning = position_ms == 0;
|
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
|
// This is only a loop to be able to reload the file if an error occured
|
||||||
// while opening a cached file.
|
// while opening a cached file.
|
||||||
loop {
|
loop {
|
||||||
|
@ -713,6 +702,14 @@ impl PlayerTrackLoader {
|
||||||
stream_loader_controller.set_random_access_mode();
|
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);
|
let mut decrypted_file = AudioDecrypt::new(key, encrypted_file);
|
||||||
|
|
||||||
let normalisation_factor = match NormalisationData::parse_from_file(&mut decrypted_file)
|
let normalisation_factor = match NormalisationData::parse_from_file(&mut decrypted_file)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue