Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion connect/src/spirc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub enum SpircCommand {
struct SpircTaskConfig {
volume_ctrl: VolumeCtrl,
autoplay: bool,
autonext: bool,
}

const CONTEXT_TRACKS_HISTORY: usize = 10;
Expand Down Expand Up @@ -254,6 +255,7 @@ impl Spirc {
session: Session,
player: Player,
mixer: Box<dyn Mixer>,
autonext : bool,
) -> (Spirc, impl Future<Output = ()>) {
debug!("new Spirc[{}]", session.session_id());

Expand Down Expand Up @@ -284,6 +286,7 @@ impl Spirc {
let task_config = SpircTaskConfig {
volume_ctrl: config.volume_ctrl.to_owned(),
autoplay: config.autoplay,
autonext: autonext,
};

let device = initial_device_state(config);
Expand Down Expand Up @@ -1023,7 +1026,10 @@ impl SpircTask {
}

fn handle_end_of_track(&mut self) {
self.handle_next();
warn!("SPIRC END OF TRACK");
if self.config.autonext {
self.handle_next();
}
self.notify(None, true);
}

Expand Down
12 changes: 11 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ async fn main() {
}
};

let (spirc_, spirc_task_) = Spirc::new(connect_config, session, player, mixer);
let (spirc_, spirc_task_) = Spirc::new(connect_config, session, player, mixer, false);

spirc = Some(spirc_);
spirc_task = Some(Box::pin(spirc_task_));
Expand Down Expand Up @@ -767,6 +767,15 @@ async fn main() {
event = async { player_event_channel.as_mut().unwrap().recv().await }, if player_event_channel.is_some() => match event {
Some(event) => {
if let Some(program) = &setup.player_event_program {
match event {
PlayerEvent::EndOfTrack { .. } => {
info!("END OF TRACK EVENT");
//spirc.as_mut().unwrap().next();
spirc.as_mut().unwrap().pause();
},
_ => info!("EVENT RECEIVED"),
}
/*
if let Some(child) = run_program_on_events(event, program) {
if child.is_ok() {

Expand All @@ -783,6 +792,7 @@ async fn main() {
error!("program failed to start");
}
}
*/
}
},
None => {
Expand Down