mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Play an alternative track if selected one is not available.
This commit is contained in:
parent
4f518fc445
commit
17d4534260
1 changed files with 12 additions and 3 deletions
|
@ -1,10 +1,10 @@
|
|||
use eventual::Async;
|
||||
use eventual::{self, Async};
|
||||
use portaudio;
|
||||
use std::sync::{mpsc, Mutex, Arc, Condvar, MutexGuard};
|
||||
use std::thread;
|
||||
use vorbis;
|
||||
|
||||
use metadata::Track;
|
||||
use metadata::{Track, TrackRef};
|
||||
use session::Session;
|
||||
use audio_decrypt::AudioDecrypt;
|
||||
use util::{self, SpotifyId, Subfile};
|
||||
|
@ -97,8 +97,17 @@ impl PlayerInternal {
|
|||
state.position_measured_at = util::now_ms();
|
||||
return true;
|
||||
});
|
||||
drop(decoder);
|
||||
|
||||
let track = self.session.metadata::<Track>(track_id).await().unwrap();
|
||||
let mut track = self.session.metadata::<Track>(track_id).await().unwrap();
|
||||
|
||||
if !track.available {
|
||||
let alternatives = track.alternatives.iter()
|
||||
.map(|alt_id| self.session.metadata::<Track>(*alt_id))
|
||||
.collect::<Vec<TrackRef>>();
|
||||
|
||||
track = eventual::sequence(alternatives.into_iter()).iter().find(|alt| alt.available).unwrap();
|
||||
}
|
||||
|
||||
let file_id = track.files[0];
|
||||
|
||||
|
|
Loading…
Reference in a new issue