mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
added queue functionality and created load_tracks
This commit is contained in:
parent
4310162b88
commit
6f962089fd
1 changed files with 13 additions and 8 deletions
21
src/spirc.rs
21
src/spirc.rs
|
@ -151,14 +151,7 @@ impl<D: SpircDelegate> SpircManager<D> {
|
||||||
self.became_active_at = util::now_ms();
|
self.became_active_at = util::now_ms();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.reload_tracks(&frame);
|
||||||
self.index = frame.get_state().get_playing_track_index();
|
|
||||||
self.tracks = frame.get_state()
|
|
||||||
.get_track()
|
|
||||||
.iter()
|
|
||||||
.filter(|track| track.get_gid().len()==16)
|
|
||||||
.map(|track| SpotifyId::from_raw(track.get_gid()))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let play = frame.get_state().get_status() == PlayStatus::kPlayStatusPlay;
|
let play = frame.get_state().get_status() == PlayStatus::kPlayStatusPlay;
|
||||||
let track = self.tracks[self.index as usize];
|
let track = self.tracks[self.index as usize];
|
||||||
|
@ -184,6 +177,9 @@ impl<D: SpircDelegate> SpircManager<D> {
|
||||||
protocol::spirc::MessageType::kMessageTypeSeek => {
|
protocol::spirc::MessageType::kMessageTypeSeek => {
|
||||||
self.delegate.seek(frame.get_position());
|
self.delegate.seek(frame.get_position());
|
||||||
}
|
}
|
||||||
|
protocol::spirc::MessageType::kMessageTypeReplace => {
|
||||||
|
self.reload_tracks(&frame);
|
||||||
|
}
|
||||||
protocol::spirc::MessageType::kMessageTypeNotify => {
|
protocol::spirc::MessageType::kMessageTypeNotify => {
|
||||||
if self.is_active && frame.get_device_state().get_is_active() {
|
if self.is_active && frame.get_device_state().get_is_active() {
|
||||||
self.is_active = false;
|
self.is_active = false;
|
||||||
|
@ -197,6 +193,15 @@ impl<D: SpircDelegate> SpircManager<D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reload_tracks(&mut self, ref frame: &protocol::spirc::Frame){
|
||||||
|
self.index = frame.get_state().get_playing_track_index();
|
||||||
|
self.tracks = frame.get_state()
|
||||||
|
.get_track()
|
||||||
|
.iter()
|
||||||
|
.filter(|track| track.get_gid().len()==16)
|
||||||
|
.map(|track| SpotifyId::from_raw(track.get_gid()))
|
||||||
|
.collect();
|
||||||
|
}
|
||||||
fn notify(&mut self, hello: bool, recipient: Option<&str>) {
|
fn notify(&mut self, hello: bool, recipient: Option<&str>) {
|
||||||
let mut pkt = protobuf_init!(protocol::spirc::Frame::new(), {
|
let mut pkt = protobuf_init!(protocol::spirc::Frame::new(), {
|
||||||
version: 1,
|
version: 1,
|
||||||
|
|
Loading…
Reference in a new issue