feat: implemented loop support in pwsp-cli

This commit is contained in:
2026-01-02 02:57:34 +03:00
parent 408f5317c4
commit 2a13c25230
4 changed files with 53 additions and 0 deletions
+29
View File
@@ -52,6 +52,12 @@ pub struct SetCurrentInputCommand {
pub name: Option<String>,
}
pub struct GetLoopCommand {}
pub struct SetLoopCommand {
pub enabled: Option<bool>,
}
#[async_trait]
impl Executable for PingCommand {
async fn execute(&self) -> Response {
@@ -256,3 +262,26 @@ impl Executable for SetCurrentInputCommand {
}
}
}
#[async_trait]
impl Executable for GetLoopCommand {
async fn execute(&self) -> Response {
let audio_player = get_audio_player().await.lock().await;
Response::new(true, audio_player.looped.to_string())
}
}
#[async_trait]
impl Executable for SetLoopCommand {
async fn execute(&self) -> Response {
let mut audio_player = get_audio_player().await.lock().await;
match self.enabled {
Some(enabled) => {
audio_player.looped = enabled;
Response::new(true, format!("Loop was set to {}", enabled))
}
None => Response::new(false, "Invalid enabled value"),
}
}
}
+8
View File
@@ -87,6 +87,14 @@ impl Request {
pub fn set_input(name: &str) -> Self {
Request::new("set_input", vec![("input_name", name)])
}
pub fn get_loop() -> Self {
Request::new("get_loop", vec![])
}
pub fn set_loop(enabled: &str) -> Self {
Request::new("set_loop", vec![("enabled", enabled)])
}
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]