fix remote volme control
Some checks failed
🏗️ Build and Test JellyTau / Run Tests (push) Failing after 12s
🏗️ Build and Test JellyTau / Build Android APK (push) Has been skipped
Traceability Validation / Check Requirement Traces (push) Failing after 1s

This commit is contained in:
Duncan Tourolle 2026-03-01 20:23:24 +01:00
parent 09780103a7
commit d6aa74fc85

View File

@ -302,24 +302,42 @@ impl JellyfinClient {
self.post(&format!("/Sessions/{}/Playing/Seek", session_id), &request).await
}
/// Send a full GeneralCommand to a remote session.
/// Uses POST /Sessions/{id}/Command with a body containing Name and Arguments.
/// This is required for commands that need arguments (e.g. SetVolume).
async fn send_general_command(
&self,
session_id: &str,
command_name: &str,
arguments: Option<serde_json::Value>,
) -> Result<(), String> {
let mut payload = serde_json::json!({
"Name": command_name,
});
if let Some(args) = arguments {
payload["Arguments"] = args;
}
log::info!("[JellyfinClient] Sending GeneralCommand '{}' to session {} with payload: {}",
command_name, session_id, serde_json::to_string(&payload).unwrap_or_default());
self.post(
&format!("/Sessions/{}/Command", session_id),
&payload
).await
}
/// Set volume on a remote session
pub async fn session_set_volume(
&self,
session_id: String,
volume: i32,
) -> Result<(), String> {
let payload = serde_json::json!({
"Arguments": {
"Volume": volume.to_string()
}
});
log::info!("[JellyfinClient] Setting volume on session {} to {} with payload: {}",
session_id, volume, serde_json::to_string(&payload).unwrap_or_default());
self.post(
&format!("/Sessions/{}/Command/SetVolume", session_id),
&payload
self.send_general_command(
&session_id,
"SetVolume",
Some(serde_json::json!({ "Volume": volume.to_string() })),
).await
}
@ -330,9 +348,10 @@ impl JellyfinClient {
) -> Result<(), String> {
log::info!("[JellyfinClient] Toggling mute on session {}", session_id);
self.post(
&format!("/Sessions/{}/Command/ToggleMute", session_id),
&serde_json::json!({})
self.send_general_command(
&session_id,
"ToggleMute",
None,
).await
}