mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Small refactor
This commit is contained in:
parent
d3495cfed4
commit
2f660f74ec
1 changed files with 15 additions and 7 deletions
|
@ -652,15 +652,23 @@ impl PlayerTrackLoader {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
let (format, file_id) = formats
|
let entry = formats.iter().find_map(|format| {
|
||||||
.iter()
|
if let Some(&file_id) = audio.files.get(format) {
|
||||||
.find_map(|format| Some((format, *audio.files.get(&format)?)))
|
Some((*format, file_id))
|
||||||
.or_else(|| {
|
} else {
|
||||||
warn!("<{}> is not available in any supported format", audio.name);
|
|
||||||
None
|
None
|
||||||
})?;
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let bytes_per_second = self.stream_data_rate(*format);
|
let (format, file_id) = match entry {
|
||||||
|
Some(t) => t,
|
||||||
|
None => {
|
||||||
|
warn!("<{}> is not available in any supported format", audio.name);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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 = self.session.audio_key().request(spotify_id, file_id);
|
let key = self.session.audio_key().request(spotify_id, file_id);
|
||||||
|
|
Loading…
Reference in a new issue