Added: Next and Previous track

Bug resolved: opening a list with "dissallowed tracks" is now possible
This commit is contained in:
Erik 2016-01-14 04:27:34 +01:00
parent f316211ba3
commit 3c8d709ff1

View file

@ -156,6 +156,7 @@ impl<D: SpircDelegate> SpircManager<D> {
self.tracks = frame.get_state()
.get_track()
.iter()
.filter(|track| track.get_gid().len()==16)
.map(|track| SpotifyId::from_raw(track.get_gid()))
.collect();
@ -170,6 +171,16 @@ impl<D: SpircDelegate> SpircManager<D> {
protocol::spirc::MessageType::kMessageTypePause => {
self.delegate.pause();
}
protocol::spirc::MessageType::kMessageTypeNext => {
self.index = (self.index + 1) % self.tracks.len() as u32;
let track = self.tracks[self.index as usize];
self.delegate.load(track, true, 0);
}
protocol::spirc::MessageType::kMessageTypePrev => {
self.index = (self.index - 1) % self.tracks.len() as u32;
let track = self.tracks[self.index as usize];
self.delegate.load(track, true, 0);
}
protocol::spirc::MessageType::kMessageTypeSeek => {
self.delegate.seek(frame.get_position());
}