use std::sync::Arc;
use std::time::Duration;
use mineral_task::{ChannelFetchKind, Priority, TaskKind};
use super::PlayerCore;
use crate::gapless;
impl PlayerCore {
pub(super) async fn background_loop(self) {
let mut tick = tokio::time::interval(Duration::from_millis(self.inner.player_tick_ms));
loop {
tick.tick().await;
self.consume_events_once();
gapless::check_advance(&self);
gapless::check_prefetch(&self);
self.check_props();
self.check_session_save();
}
}
pub fn refresh_initial_loads(&self) {
self.push_cached_library_snapshot();
self.replay_current_envelope();
for ch in &self.inner.channels {
let source = ch.source();
self.submit_my_playlists(source);
self.inner.scheduler.submit(
TaskKind::ChannelFetch(ChannelFetchKind::MyAlbums { source }),
Priority::User,
);
let this = self.clone();
let channel = Arc::clone(ch);
tokio::spawn(async move {
this.sync_favorites(source, channel).await;
});
}
self.spawn_meta_backfill();
}
}