feat: implemented toggle-loop

This commit is contained in:
2026-01-02 04:39:48 +03:00
parent 023caa4616
commit 6c06da7b0d
4 changed files with 19 additions and 0 deletions
+11
View File
@@ -58,6 +58,8 @@ pub struct SetLoopCommand {
pub enabled: Option<bool>,
}
pub struct ToggleLoopCommand {}
#[async_trait]
impl Executable for PingCommand {
async fn execute(&self) -> Response {
@@ -285,3 +287,12 @@ impl Executable for SetLoopCommand {
}
}
}
#[async_trait]
impl Executable for ToggleLoopCommand {
async fn execute(&self) -> Response {
let mut audio_player = get_audio_player().await.lock().await;
audio_player.looped = !audio_player.looped;
Response::new(true, format!("Loop was set to {}", audio_player.looped))
}
}
+4
View File
@@ -95,6 +95,10 @@ impl Request {
pub fn set_loop(enabled: &str) -> Self {
Request::new("set_loop", vec![("enabled", enabled)])
}
pub fn toggle_loop() -> Self {
Request::new("toggle_loop", vec![])
}
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]