feat: implemented loop functionality on daemon level

This commit is contained in:
2026-01-02 02:25:30 +03:00
parent 3672d6f43e
commit 408f5317c4
2 changed files with 23 additions and 2 deletions
+18 -1
View File
@@ -126,5 +126,22 @@ async fn commands_loop(listener: UnixListener) -> Result<(), Box<dyn Error>> {
}
async fn player_loop() {
loop {}
loop {
let mut audio_player = get_audio_player().await.lock().await;
// Start playback again if loop is enabled
let should_play = audio_player.get_state() == PlayerState::Stopped
&& audio_player.current_file_path.is_some()
&& audio_player.looped;
if should_play {
let file_path = audio_player.current_file_path.clone().unwrap();
audio_player
.play(&file_path)
.await
.expect("Something went wrong while trying to play the file");
}
sleep(Duration::from_millis(100)).await;
}
}