陈嘉乐
2020-05-26 c209a50cabf524c146fb2d02ce09cfc46c7c2f70
HDL_ON/UI/Music/A31MusicModel.cs
@@ -172,47 +172,7 @@
            }
        }
        /// <summary>
        /// 调节音量
        /// </summary>
        /// <param name="volume">Volume.</param>
        public void ControlVolume(int volume)
        {
            System.Threading.Tasks.Task.Run(() => {
                ProgressDateTime = DateTime.Now;
                try
                {
                    if (ServerClientType == -1)
                    {
                        new System.Net.WebClient().DownloadData(new Uri("http://" + ServerIP + "/httpapi.asp?command=multiroom:SlaveVolume:" + IPAddress + ":" + volume));
                    }
                    else if (ServerClientType == 1)
                    {
                        new System.Net.WebClient().DownloadData(new Uri("http://" + IPAddress + "/httpapi.asp?command=setPlayerCmd:slave_vol:" + volume));
                    }
                    else
                    {
                        var sb = new StringBuilder();
                        sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
                        sb.AppendLine("<s:Body>");
                        sb.AppendLine("<u:SetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\">");
                        sb.AppendLine("<InstanceID>0</InstanceID>");
                        sb.AppendLine("<Channel>Master</Channel>");
                        sb.AppendLine("<DesiredVolume>" + volume + "</DesiredVolume>");
                        sb.AppendLine("</u:SetVolume>");
                        sb.AppendLine("</s:Body>");
                        sb.AppendLine("</s:Envelope>");
                        var webClient =new System.Net.WebClient();
                        webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:RenderingControl:1#SetVolume\"");
                        webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
                        webClient.UploadData(new Uri("http://" + IPAddress + ":" + Port + "/upnp/control/rendercontrol1"), "POST", Encoding.UTF8.GetBytes(sb.ToString()));
                    }
                }
                catch { }
            });
        }
        
    }