陈嘉乐
2020-06-16 7167334c0e89dd84827d59e726123d14776e3a09
HDL_ON/UI/Music/A31MusicModel.cs
@@ -50,6 +50,8 @@
        public string Name=string.Empty;
        /// <summary>
        /// 上一次更新的时间
        /// 记录数据反馈的时间(因为有时间网络差数据不回复,导致刷新当前播放音乐时间不正确)
        /// ((当前时间)DateTime.Now - (记录时间)LastDateTimeLastDateTime).TotalSeconds=误差时间(秒)
        /// </summary>
        public DateTime LastDateTime;
        /// <summary>
@@ -62,8 +64,10 @@
        /// </summary>
        public int Port = 49153;
        public bool IsEnd;
        /// <summary>
        /// 是否是播放器列表最后一个(true)
        /// </summary>
        public bool IsEnd=false;
        public int A31DeviceType;
@@ -144,10 +148,13 @@
        /// </summary>
        public int ServerClientType;
        /// <summary>
        /// 表示从的播放器IP
        /// 记录主播放器IP
        /// </summary>
        public string ServerIP = string.Empty;
        public string MainPlayIP = string.Empty;
        /// <summary>
        /// 记录主播放器名称
        /// </summary>
        public string MainPlayName = string.Empty;
        public Slaves Slave = new Slaves();
@@ -172,47 +179,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 { }
            });
        }
        
    }