diff --git a/playback/src/player.rs b/playback/src/player.rs index 404493f5b..125184a01 100644 --- a/playback/src/player.rs +++ b/playback/src/player.rs @@ -101,6 +101,10 @@ pub enum PlayerEvent { track_id: SpotifyId, position_ms: u32, }, + // The player is preloading a track. + Preloading { + track_id: SpotifyId, + }, // The player is playing a track. // This event is issued at the start of playback of whenever the position must be communicated // because it is out of sync. This includes: @@ -173,7 +177,7 @@ impl PlayerEvent { | Stopped { play_request_id, .. } => Some(*play_request_id), - Changed { .. } | VolumeSet { .. } => None, + Changed { .. } | Preloading { .. } | VolumeSet { .. } => None, } } } @@ -799,6 +803,7 @@ impl Future for PlayerInternal { { match loader.poll() { Ok(Async::Ready(loaded_track)) => { + self.send_event(PlayerEvent::Preloading { track_id }); self.preload = PlayerPreload::Ready { track_id, loaded_track, diff --git a/src/player_event_handler.rs b/src/player_event_handler.rs index 00b6c09f1..4ce66c5ef 100644 --- a/src/player_event_handler.rs +++ b/src/player_event_handler.rs @@ -58,6 +58,10 @@ pub fn run_program_on_events(event: PlayerEvent, onevent: &str) -> Option { + env_vars.insert("PLAYER_EVENT", "preloading".to_string()); + env_vars.insert("TRACK_ID", track_id.to_base62()); + } PlayerEvent::VolumeSet { volume } => { env_vars.insert("PLAYER_EVENT", "volume_set".to_string()); env_vars.insert("VOLUME", volume.to_string());