From 8951d8a305b0769392b90c731042e52540365031 Mon Sep 17 00:00:00 2001 From: Nerothe Date: Wed, 18 Oct 2017 11:57:29 +0200 Subject: [PATCH] Added volume control to player. --- Jishi.Intel.SonosUPnP/SonosPlayer.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Jishi.Intel.SonosUPnP/SonosPlayer.cs b/Jishi.Intel.SonosUPnP/SonosPlayer.cs index 630e1d4..5b00c3a 100644 --- a/Jishi.Intel.SonosUPnP/SonosPlayer.cs +++ b/Jishi.Intel.SonosUPnP/SonosPlayer.cs @@ -366,6 +366,26 @@ public void Pause() arguments[0] = new UPnPArgument("InstanceID", 0u); AVTransport.InvokeAsync("Pause", arguments); } + + public ushort GetVolume() + { + var arguments = new UPnPArgument[3]; + arguments[0] = new UPnPArgument("InstanceID", 0u); + arguments[1] = new UPnPArgument("Channel", "Master"); + arguments[2] = new UPnPArgument("CurrentVolume", 0u); + RenderingControl.InvokeSync("GetVolume", arguments); + return (ushort) arguments[2].DataValue; + } + + public void SetVolume(ushort vol) + { + vol = Math.Min(Math.Max(vol, (ushort)0), (ushort)100); + var arguments = new UPnPArgument[3]; + arguments[0] = new UPnPArgument("InstanceID", 0u); + arguments[1] = new UPnPArgument("Channel", "Master"); + arguments[2] = new UPnPArgument("DesiredVolume", vol); + RenderingControl.InvokeAsync("SetVolume", arguments); + } public IList GetQueue() {