From b7724b7823c1172f30178c3628218acef90f84b6 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期二, 02 六月 2020 12:01:34 +0800 Subject: [PATCH] 2020-06-2-1 --- HDL_ON/UI/Music/View/DialogView.cs | 196 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 179 insertions(+), 17 deletions(-) diff --git a/HDL_ON/UI/Music/View/DialogView.cs b/HDL_ON/UI/Music/View/DialogView.cs index 55f9d6e..0d75a38 100644 --- a/HDL_ON/UI/Music/View/DialogView.cs +++ b/HDL_ON/UI/Music/View/DialogView.cs @@ -311,7 +311,7 @@ Width = Application.GetRealWidth(344), }; dialogFra.AddChidren(verticalScrolViewLayout); - var playList = new List<A31MusicModel>(); + var playList1 = new List<A31MusicModel>(); for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) { var player = A31MusicModel.A31MusicModelList[i]; @@ -367,19 +367,19 @@ { clickBtn.IsSelected = !clickBtn.IsSelected; selectedIconBtn.IsSelected = clickBtn.IsSelected; - var musicPlayer = playList.Find((c) => c.UniqueDeviceName == player.UniqueDeviceName); + var musicPlayer = playList1.Find((c) => c.UniqueDeviceName == player.UniqueDeviceName); if (selectedIconBtn.IsSelected) { if (musicPlayer == null) { - playList.Add(player); + playList1.Add(player); } } else { if (musicPlayer != null) { - playList.Remove(player); + playList1.Remove(player); } } }; @@ -396,20 +396,47 @@ } confirmBtn.MouseUpEventHandler += (sender, e) => { - if (playList.Count <= 1) + if (playList1.Count <= 1) { new PublicAssmebly().TipMsgAutoClose("鑷冲皯閫変腑涓や釜浠ヤ笂鎾斁鍣�", false); return; } - PlayerView(dialog, playList); + + var playList2 = new List<A31MusicModel>(); + for (int i = 0; i < playList1.Count; i++) + { + var musics = playList1[i]; + if (musics.A31PlayStatus.playSource == "play") + { + playList2.Add(musics); + } + + } + + if (playList2.Count == 0) + { + PlayerView(dialog, playList1, playList1); + } + else if (playList2.Count == 1) + { + dialog.Close(); + var player = playList2[0]; + Threading(player, playList1); + } + else + { + PlayerView(dialog, playList1, playList2); + } }; } /// <summary> /// 閫変腑涓绘挱鏀惧櫒鐨勭晫闈� /// </summary> - /// <param name="musicList"></param> - void PlayerView(Dialog dialogF ,List<A31MusicModel> musicList) + /// <param name="musicList1"></param> + /// /// <param name="musicList2">鏄剧ず鎾斁鍣ㄥ垪琛�</param> + void PlayerView(Dialog dialogF, List<A31MusicModel> musicList1, List<A31MusicModel> musicList2) { + //涓绘帶浠� Dialog dialog = new Dialog() { @@ -472,7 +499,6 @@ IsBold = true, }; topFra.AddChidren(txetBtn); - //纭鎺т欢 Button confirmBtn = new Button { @@ -486,10 +512,7 @@ TextSize = TextSize.Text14, }; topFra.AddChidren(confirmBtn); - confirmBtn.MouseUpEventHandler += (sender, e) => - { - }; VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout { Y = Application.GetRealHeight(50), @@ -498,10 +521,10 @@ }; dialogFra.AddChidren(verticalScrolViewLayout); //璁板綍閫変腑鐘舵�� - Button selectedBtn = new Button() { Tag="No"}; - for (int i = 0; i < musicList.Count; i++) + Button selectedBtn = new Button() { Name = "No" }; + for (int i = 0; i < musicList2.Count; i++) { - var player = musicList[i]; + var player = musicList2[i]; RowLayout addFlieRow = new RowLayout { Height = Application.GetRealHeight(50), @@ -532,6 +555,7 @@ Height = Application.GetMinRealAverage(28), UnSelectedImagePath = "MusicIcon/noSelectedIcon.png", SelectedImagePath = "MusicIcon/selectedIcon.png", + Tag = player, }; addFlieRow.AddChidren(selectedIconBtn); ///鍔犲ぇ鍑犵偣鑼冨洿 @@ -543,8 +567,8 @@ clickBtn.MouseUpEventHandler += (sender, e) => { selectedBtn.IsSelected = false; - selectedBtn.Tag = "Yes"; selectedBtn = selectedIconBtn; + selectedBtn.Name = "Yes"; selectedBtn.IsSelected = true; }; //绾� @@ -561,15 +585,153 @@ confirmBtn.MouseUpEventHandler += (sender, e) => { - if (selectedBtn.Tag.ToString() == "No") + if (selectedBtn.Name.ToString() == "No") { new PublicAssmebly().TipMsgAutoClose("杩樻病閫変腑鎾斁鍣�", false); return; } dialogF.Close(); dialog.Close(); + var serverMusic = selectedBtn.Tag as A31MusicModel; + Threading(serverMusic, musicList1); + + }; } + + /// <summary> + /// 鍙戦�佺粍鍚堝懡浠ら�昏緫澶勭悊鐨勬柟娉� + /// </summary> + /// <param name="serverMusic">涓绘挱鏀惧櫒</param> + /// <param name="musicList1"></param> + void Threading(A31MusicModel serverMusic, List<A31MusicModel> musicList1) + { + System.Threading.Tasks.Task.Run(() => + { + try + { + + var IP = ""; + if (serverMusic.ServerClientType == -1) + { + IP = serverMusic.MainPlayIP; + } + else + { + IP = serverMusic.IPAddress; + } + + var statusEx = SendMethod.OpenWeb("http://" + IP + "/httpapi.asp?command=getStatusEx"); + if (statusEx == null) + { + statusEx = SendMethod.OpenWeb("http://" + IP + "/httpapi.asp?command=getStatusEx"); + } + if (statusEx == null) + { + return; + } + var serverIfon = Newtonsoft.Json.JsonConvert.DeserializeObject<A31Wifi>(statusEx); + if (serverIfon == null) + { + return; + } + string ssid = ""; + foreach (var b in serverIfon.ssid) + { + ssid += System.Convert.ToString(b, 16).ToUpper().Length < 2 ? "0" + System.Convert.ToString(b, 16).ToUpper() : System.Convert.ToString(b, 16).ToUpper(); + } + System.Threading.Thread.Sleep(1000); + for (int i = 0; i < musicList1.Count; i++) + { + var clientMusic = musicList1[i]; + if (clientMusic.UniqueDeviceName == serverMusic.UniqueDeviceName) + { + //杩囨护鎺変富鎾斁鍣�; + continue; + } + if (null == SendMethod.OpenWeb("http://" + clientMusic.IPAddress + "/httpapi.asp?command=ConnectMasterAp:ssid=" + ssid + ":ch=" + serverIfon.WifiChannel + ":auth=OPEN:encry=NONE:pwd=:chext=0:JoinGroupMaster:eth" + serverIfon.eth2 + ":wifi" + serverIfon.ra0 + ":uuid" + serverIfon.uuid)) + { + if (null == SendMethod.OpenWeb("http://" + clientMusic.IPAddress + "/httpapi.asp?command=ConnectMasterAp:ssid=" + ssid + ":ch=" + serverIfon.WifiChannel + ":auth=OPEN:encry=NONE:pwd=:chext=0:JoinGroupMaster:eth" + serverIfon.eth2 + ":wifi" + serverIfon.ra0 + ":uuid" + serverIfon.uuid)) + { + + } + } + } + DateTime dateTime = DateTime.Now; + while ((DateTime.Now - dateTime).TotalMilliseconds < 10 * 1000) + { + System.Threading.Thread.Sleep(1000); + try + { + var result = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); + if (result != null) + { + var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result); + if (tmepSlaves != null && tmepSlaves.slave_list != null) + { + string str = serverMusic.Name; + for (int j = 0; j < A31MusicModel.A31MusicModelList.Count; j++) + { + var music = A31MusicModel.A31MusicModelList[j]; + if (music.UniqueDeviceName == serverMusic.UniqueDeviceName) + { + + music.ServerClientType = 1; + music.Slave = tmepSlaves; + //杩囨护鎺変富鎾斁鍣�; + continue; + } + var slave_Ifon = tmepSlaves.slave_list.Find((obj) => obj.uuid.Replace("uuid:", "") == music.UniqueDeviceName); + if (null != slave_Ifon) + { + str = str + "+" + slave_Ifon.name; + //宸茬粡娣诲姞鎴愬姛 + music.ServerClientType = -1; + music.IsCanShow = false; + music.IsOnLine = false; + music.IPAddress = slave_Ifon.ip; + music.MainPlayIP = serverMusic.IPAddress; + } + } + serverMusic.MainPlayName = str; + A31MusicModel.Save(); + break; + } + } + } + catch { } + } + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + MainPage.BasePageView.RemoveViewByTag("MusicMain"); + var musicMain = new MusicMain(); + MainPage.BasePageView.AddChidren(musicMain); + musicMain.Show(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }); + } + }); + + } + } + [System.Serializable] + public class A31Wifi鈥� { + public string ssid;鈥� public string WifiChannel;鈥� public string uuid;鈥� public string eth2;鈥� public string ra0;鈥� public string upnp_uuid; + public string firmware; + public string language; + public string MAC; + public string Release; + public string psk; + public string SSIDStrategy; + public string netstat; + public string apcli0; +鈥� } + + } -- Gitblit v1.8.0