fix remote volme control
This commit is contained in:
parent
09780103a7
commit
d6aa74fc85
@ -302,24 +302,42 @@ impl JellyfinClient {
|
|||||||
self.post(&format!("/Sessions/{}/Playing/Seek", session_id), &request).await
|
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
|
/// Set volume on a remote session
|
||||||
pub async fn session_set_volume(
|
pub async fn session_set_volume(
|
||||||
&self,
|
&self,
|
||||||
session_id: String,
|
session_id: String,
|
||||||
volume: i32,
|
volume: i32,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let payload = serde_json::json!({
|
self.send_general_command(
|
||||||
"Arguments": {
|
&session_id,
|
||||||
"Volume": volume.to_string()
|
"SetVolume",
|
||||||
}
|
Some(serde_json::json!({ "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
|
|
||||||
).await
|
).await
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,9 +348,10 @@ impl JellyfinClient {
|
|||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
log::info!("[JellyfinClient] Toggling mute on session {}", session_id);
|
log::info!("[JellyfinClient] Toggling mute on session {}", session_id);
|
||||||
|
|
||||||
self.post(
|
self.send_general_command(
|
||||||
&format!("/Sessions/{}/Command/ToggleMute", session_id),
|
&session_id,
|
||||||
&serde_json::json!({})
|
"ToggleMute",
|
||||||
|
None,
|
||||||
).await
|
).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user