From 8ca9f1965c199cb3509287aeb8fb53f0e2e63e40 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期四, 04 六月 2020 16:31:09 +0800
Subject: [PATCH] 2020-06-04-2

---
 HDL_ON/UI/Music/View/DialogView.cs |  534 +++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 318 insertions(+), 216 deletions(-)

diff --git a/HDL_ON/UI/Music/View/DialogView.cs b/HDL_ON/UI/Music/View/DialogView.cs
index 3b45ea7..e4654dd 100644
--- a/HDL_ON/UI/Music/View/DialogView.cs
+++ b/HDL_ON/UI/Music/View/DialogView.cs
@@ -11,6 +11,7 @@
         /// <param name="musicInfo"></param>
         public void FieListView(MusicInfo musicInfo)
         {
+            #region
             //涓绘帶浠�
             Dialog dialog = new Dialog()
             {
@@ -85,7 +86,7 @@
             };
             topFra.AddChidren(addIconBtn);
 
-
+            #endregion
             VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout
             {
                 Y = Application.GetRealHeight(70),
@@ -113,7 +114,6 @@
             FileView(dialog, verticalScrolViewLayout, musicInfo);
 
         }
-
         void FileView(Dialog dialog, VerticalScrolViewLayout verticalScrolViewLayout, MusicInfo musicInfo)
         {
             verticalScrolViewLayout.RemoveAll();
@@ -227,6 +227,9 @@
         /// </summary>
         public void PlayMergence()
         {
+
+            #region
+
             //涓绘帶浠�
             Dialog dialog = new Dialog()
             {
@@ -394,51 +397,62 @@
                 };
                 PlayRow.AddChidren(lineBtn);
             }
+            #endregion
             confirmBtn.MouseUpEventHandler += (sender, e) =>
             {
-             
 
                 if (playList1.Count <= 1)
                 {
                     new PublicAssmebly().TipMsgAutoClose("鑷冲皯閫変腑涓や釜浠ヤ笂鎾斁鍣�", false);
                     return;
                 }
-
-                var playList2 = new List<A31MusicModel>();
-                for (int i = 0; i < playList1.Count; i++)
+                ///鏌ヨ鏄惁宸茬粡瀛樺湪涓绘挱鏀�;
+                var host_Music_If = playList1.Find((c) => c.ServerClientType == 1);
+                if (host_Music_If == null)
                 {
-                    var musics = playList1[i];
-                    if (musics.A31PlayStatus.playSource == "play")
+
+                    var playList2 = new List<A31MusicModel>();
+                    for (int i = 0; i < playList1.Count; i++)
                     {
-                        playList2.Add(musics);
+                        var musics = playList1[i];
+                        if (musics.A31PlayStatus.status == "play")
+                        {
+                            playList2.Add(musics);
+                        }
+
                     }
 
-                }
-
-                if (playList2.Count == 0)
-                {
-                    SelectedPlayerView(dialog, playList1, playList1);
-                }
-                else if (playList2.Count == 1)
-                {
-                    dialog.Close();
-                    var player = playList2[0];
-                    Threading(player, playList1);
+                    if (playList2.Count == 0)
+                    {
+                        SelectedPlayerView(dialog, playList1, playList1);
+                    }
+                    else if (playList2.Count == 1)
+                    {
+                        //鍙湁涓�涓挱鏀惧櫒鍦ㄦ挱鏀�,榛樿涓轰富鎾彂鍣�;
+                        dialog.Close();
+                        var player = playList2[0];
+                        MergeThreading(player, playList1);
+                    }
+                    else
+                    {
+                        SelectedPlayerView(dialog, playList1, playList2);
+                    }
                 }
                 else
                 {
-                    SelectedPlayerView(dialog, playList1, playList2);
+                    dialog.Close();
+                    MergeThreading(host_Music_If, playList1);
                 }
             };
         }
         /// <summary>
-        /// 閫変腑涓绘挱鏀惧櫒鐨勭晫闈�
+        /// 閫変腑鏌愪釜闊充箰涓轰富鎾斁鍣ㄧ殑鐣岄潰
         /// </summary>
         /// <param name="musicList1">鏄剧ず灏嗚缁勫悎鐨勬挱鏀惧櫒鍒楄〃</param>
         ///  /// <param name="musicList2">鏄剧ず鍦ㄦ挱鏀鹃煶涔愭挱鏀惧櫒鍒楄〃</param>
         void SelectedPlayerView(Dialog dialogF, List<A31MusicModel> musicList1, List<A31MusicModel> musicList2)
         {
-
+            #region
             //涓绘帶浠�
             Dialog dialog = new Dialog()
             {
@@ -584,7 +598,7 @@
                 };
                 addFlieRow.AddChidren(lineBtn);
             }
-
+            #endregion
             confirmBtn.MouseUpEventHandler += (sender, e) =>
             {
                 if (selectedBtn.Name.ToString() == "No")
@@ -596,135 +610,17 @@
                 dialog.Close();
                
                 var serverMusic = selectedBtn.Tag as A31MusicModel;
-                Threading(serverMusic, musicList1);
+                MergeThreading(serverMusic, musicList1);
             };
 
         }
-
         /// <summary>
-        /// 鍙戦�佺粍鍚堝懡浠ら�昏緫澶勭悊鐨勬柟娉�
-        /// </summary>
-        /// <param name="serverMusic">涓绘挱鏀惧櫒</param>
-        /// <param name="musicList1"></param>
-        void Threading(A31MusicModel serverMusic, List<A31MusicModel> musicList1)
-        {
-            MusicMain.loading.Start("閰嶇疆涓�...");
-            bool _if = false;
-            System.Threading.Tasks.Task.Run(() =>
-            {
-                try
-                {
-                    var statusEx = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=getStatusEx");
-                    if (statusEx == null)
-                    {
-                        statusEx = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/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;
-                        }
-                        System.Threading.Thread.Sleep(1000);//绛夊緟涓�绉掑啀鍙戞暟鎹�
-                        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 < 12 * 1000)
-                    {
-                        System.Threading.Thread.Sleep(1000);
-                        try
-                        {
-                            var result = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList");
-                            if (result != null && result != "Failed")
-                            {
-                                var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result);
-                                if (tmepSlaves != null && tmepSlaves.slave_list != null && tmepSlaves.slave_list.Count != 0)
-                                {
-                                    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;
-                                            _if = true;
-                                        }
-                                    }
-                                    serverMusic.MainPlayName = str;
-                                    A31MusicModel.Save();
-                                    break;
-                                }
-                            }
-
-
-                        }
-                        catch { }
-                    }
-                }
-                catch { }
-                finally
-                {
-                    Application.RunOnMainThread(() =>
-                    {
-                        MusicMain.loading.Hide();
-                        ///鍙互鎻愮ず閰嶇疆澶辫触;
-                        if (_if)
-                        {
-                            //閰嶇疆鎴愬姛鎵嶅彲浠ュ埛鏂扮晫闈�
-                            MainPage.BasePageView.RemoveViewByTag("MusicMain");
-                            var musicMain = new MusicMain();
-                            MainPage.BasePageView.AddChidren(musicMain);
-                            musicMain.Show();
-                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
-                        }
-                    });
-                }
-            });
-
-        }
-        /// <summary>
-        /// 鍒嗗紑缁勫悎鐨勬挱鏀惧櫒鐨勭晫闈�
+        /// 閫変腑瑙i櫎缁勫悎鐨勬挱鏀惧櫒鐨勭晫闈�
         /// </summary>
         public void DetachPlayMergence(A31MusicModel a31player)
         {
+
+            #region
             //涓绘帶浠�
             Dialog dialog = new Dialog()
             {
@@ -810,10 +706,24 @@
                 Width = Application.GetRealWidth(344),
             };
             dialogFra.AddChidren(verticalScrolViewLayout);
-            var  slaveList= new List<Slave>();
+
+            var playList1 = new List<A31MusicModel>();
+            playList1.Add(a31player);
             for (int i = 0; i < a31player.Slave.slave_list.Count; i++)
             {
                 var slave = a31player.Slave.slave_list[i];
+                var music_If = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == slave.uuid.Replace("uuid:", ""));
+                if (music_If != null)
+                {
+                    playList1.Add(music_If);
+                }
+            }
+
+
+            var playList2 = new List<A31MusicModel>();
+            for (int i = 0; i < playList1.Count; i++)
+            {
+                var player = playList1[i];
                 RowLayout PlayRow = new RowLayout
                 {
                     Height = Application.GetRealHeight(50),
@@ -833,7 +743,7 @@
                     TextColor = Color.TextColor,
                     TextSize = TextSize.Text14,
                     TextAlignment = TextAlignment.CenterLeft,
-                    Text = slave.name,
+                    Text = player.Name,
                 };
                 PlayRow.AddChidren(PlayNameBtn);
 
@@ -854,7 +764,7 @@
                 Button clickBtn = new Button
                 {
                     Height = Application.GetRealHeight(50),
-                    Tag = slave.uuid.Replace("uuid:", ""),
+                    Tag = player.UniqueDeviceName,
                 };
                 PlayRow.AddChidren(clickBtn);
 
@@ -862,19 +772,19 @@
                 {
                     clickBtn.IsSelected = !clickBtn.IsSelected;
                     selectedIconBtn.IsSelected = clickBtn.IsSelected;
-                    var uuid = slaveList.Find((obj) => obj.uuid.Replace("uuid:", "") == clickBtn.Tag.ToString());
+                    var uuid = playList2.Find((obj) => obj.UniqueDeviceName== clickBtn.Tag.ToString());
                     if (selectedIconBtn.IsSelected)
                     {
                         if (uuid == null)
                         {
-                            slaveList.Add(slave);
+                            playList2.Add(player);
                         }
                     }
                     else
                     {
                         if (uuid != null)
                         {
-                            slaveList.Remove(slave);
+                            playList2.Remove(player);
                         }
                     }
                 };
@@ -889,79 +799,271 @@
                 };
                 PlayRow.AddChidren(lineBtn);
             }
+            #endregion
             confirmBtn.MouseUpEventHandler += (sender, e) =>
             {
-                if (slaveList.Count == 0)
+                if (playList1.Count == 0)
                 {
                     new PublicAssmebly().TipMsgAutoClose("杩樻病鏈夐�夋嫨瑙i櫎缁勬挱鏀惧櫒", false);
                     return;
                 }
                 dialog.Close();
-
-                MusicMain.loading.Start("瑙i櫎涓�...");
-                bool _if = false;
-                System.Threading.Tasks.Task.Run(() =>
-                {
-                    try
-                    {
-                        for (int i = 0; i < slaveList.Count; i++)
-                        {
-                            var clientMusic = slaveList[i];
-                            if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:SlaveKickout:" + clientMusic.ip))
-                            {
-                                if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:SlaveKickout:" + clientMusic.ip))
-                                {
-
-                                }
-                            }
-                            System.Threading.Thread.Sleep(2000);//绛夊緟2绉掑啀鍙戞暟鎹�
-
-                        }
-                        DateTime dateTime = DateTime.Now;
-                        while ((DateTime.Now - dateTime).TotalMilliseconds < 10 * 1000)
-                        {
-                            System.Threading.Thread.Sleep(1000);
-                            try
-                            {
-                                var result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList");
-                                if (result != null && result != "Failed")
-                                {
-                                    var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result);
-                                    if (tmepSlaves != null && tmepSlaves.slave_list.Count == 0)
-                                    {
-                                        _if = true;//瑙i櫎鎴愬姛
-                                        A31MusicModel.Save();
-                                        break;
-                                    }
-                                }
-
-
-                            }
-                            catch { }
-                        }
-                    }
-                    catch { }
-                    finally
-                    {
-                        Application.RunOnMainThread(() =>
-                        {
-                            MusicMain.loading.Hide();
-                            ///鍙互鎻愮ず瑙i櫎澶辫触;
-                            if (_if)
-                            {
-                                //瑙i櫎鎴愬姛鎵嶅彲浠ュ埛鏂扮晫闈�
-                                MainPage.BasePageView.RemoveViewByTag("MusicMain");
-                                var musicMain = new MusicMain();
-                                MainPage.BasePageView.AddChidren(musicMain);
-                                musicMain.Show();
-                                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
-                            }
-                        });
-                    }
-                });
-               
+                RemoveThreading(a31player, playList2);
             };
       }
+        /// <summary>
+        /// 鍙戦�佺粍鍚堝懡浠ら�昏緫澶勭悊鐨勬柟娉�
+        /// </summary>
+        /// <param name="serverMusic">涓绘挱鏀惧櫒</param>
+        /// <param name="musicList1"></param>
+        void MergeThreading(A31MusicModel serverMusic, List<A31MusicModel> musicList1)
+        {
+            MusicMain.loading.Start("閰嶇疆涓�...");
+            bool _if = false;
+            System.Threading.Tasks.Task.Run(() =>
+            {
+                try
+                {
+                    var statusEx = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=getStatusEx");
+                    if (statusEx == null)
+                    {
+                        statusEx = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/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;
+                        }
+                        var dd = 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))
+                        {
+                            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))
+                            {
+
+                            }
+                        }
+                        System.Threading.Thread.Sleep(1000);//绛夊緟1绉掑啀鍙戞暟鎹�
+                    }
+                    DateTime dateTime = DateTime.Now;
+                    while ((DateTime.Now - dateTime).TotalMilliseconds < 15 * 1000)
+                    {
+                        System.Threading.Thread.Sleep(1000);
+                        try
+                        {
+                            var result = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList");
+                            if (result != null && result != "Failed")
+                            {
+                                var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result);
+                                if (tmepSlaves != null && tmepSlaves.slave_list != null && tmepSlaves.slave_list.Count != 0)
+                                {
+                                    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;
+                                            _if = true;
+                                        }
+                                    }
+                                    serverMusic.MainPlayName = str;
+                                    A31MusicModel.Save();
+                                    break;
+                                }
+                            }
+
+
+                        }
+                        catch { }
+                    }
+                }
+                catch { }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        MusicMain.loading.Hide();
+                        ///鍙互鎻愮ず閰嶇疆澶辫触;
+                        if (_if)
+                        {
+                            //閰嶇疆鎴愬姛鎵嶅彲浠ュ埛鏂扮晫闈�
+                            MainPage.BasePageView.RemoveViewByTag("MusicMain");
+                            var musicMain = new MusicMain();
+                            MainPage.BasePageView.AddChidren(musicMain);
+                            musicMain.Show();
+                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                        }
+                    });
+                }
+            });
+
+        }
+        /// <summary>
+        /// 瑙i櫎缁勫悎鍛戒护閫昏緫澶勭悊鐨勬柟娉�
+        /// </summary>
+        /// <param name="a31player">涓绘挱鏀惧櫒</param>
+        /// <param name="playList1"></param>
+        void RemoveThreading(A31MusicModel a31player, List<A31MusicModel> playList1)
+        {
+            MusicMain.loading.Start("瑙i櫎涓�...");
+            var slaveList = new List<Slave>();
+            slaveList.AddRange(a31player.Slave.slave_list);
+            bool host_If = false; //琛ㄧず鏄惁鏄剧ず瑙i櫎鐨勬挱鏀�
+            bool _if = false;
+            System.Threading.Tasks.Task.Run(() =>
+            {
+                try
+                {
+                    var play_If = playList1.Find((obj) => obj.UniqueDeviceName == a31player.UniqueDeviceName);
+                    if (play_If == null)
+                    {
+                        host_If = false;
+                        //瀛愰煶绠变笌涓婚煶绠辨柇寮�鐨勫懡浠�
+                        for (int i = 0; i < playList1.Count; i++)
+                        {
+                            var clientMusic = playList1[i];
+                            if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:SlaveKickout:" + clientMusic.IPAddress))
+                            {
+                                if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:SlaveKickout:" + clientMusic.IPAddress))
+                                {
+
+                                }
+                            }
+                            ///姣忚В闄や竴涓挱鏀惧櫒闇�瑕佺瓑寰�3绉�
+                            System.Threading.Thread.Sleep(3000);//绛夊緟3绉掑啀鍙戞暟鎹�
+                        }
+                    }
+                    else
+                    {
+                        host_If = true;
+                        //瑙f暎缁勭殑鍛戒护
+                        if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:Ungroup"))
+                        {
+                            if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:Ungroup"))
+                            {
+
+                            }
+                        }
+                    }
+                    DateTime dateTime = DateTime.Now;
+                    while ((DateTime.Now - dateTime).TotalMilliseconds < 12 * 1000)
+                    {
+                        System.Threading.Thread.Sleep(1000);
+                        try
+                        {
+                            var result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList");
+                            if (result != null && result != "Failed")
+                            {
+                                var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result);
+                                if (tmepSlaves != null)
+                                {
+                                    if (host_If && tmepSlaves.slave_list.Count == 0)
+                                    {
+
+                                        var host_music = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == a31player.UniqueDeviceName);
+                                        if (host_music != null)
+                                        {
+                                            host_music.ServerClientType = 0;//瑙i櫎涓讳粠鍏崇郴
+                                            host_music.MainPlayName = "";
+                                        }
+                                        for (int a = 0; a < slaveList.Count; a++)
+                                        {
+                                            var uuid = slaveList[a].uuid.Replace("uuid:", "");
+                                            var music = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == uuid);
+                                            if (music != null)
+                                            {
+                                                music.ServerClientType = 0;//瑙i櫎涓讳粠鍏崇郴
+                                                music.IsCanShow = true;//鍏佽鏄剧ず
+                                                music.IsOnLine = false;//鍏堜笉鍏佽璇诲彇
+                                            }
+                                        }
+                                    }
+                                    else
+                                    {
+                                        for (int a = 0; a < playList1.Count; a++)
+                                        {
+                                            var uuid = playList1[a].UniqueDeviceName;
+                                            var music = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == uuid);
+                                            if (music != null)
+                                            {
+                                                music.ServerClientType = 0;//瑙i櫎涓讳粠鍏崇郴
+                                                music.IsCanShow = true;//鍏佽鏄剧ず
+                                                music.IsOnLine = false;//鍏堜笉鍏佽璇诲彇
+                                            }
+                                        }
+                                    }
+
+                                    var host_a31player = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == a31player.UniqueDeviceName);
+                                    string str = host_a31player.Name;
+                                    for (int b = 0; b < tmepSlaves.slave_list.Count; b++)
+                                    {
+                                        str = str + "+" + tmepSlaves.slave_list[b].name;
+                                    }
+                                    host_a31player.MainPlayName = str;///鏀瑰彉涓绘挱鏀惧櫒鐨勬樉绀哄悕绉�
+                                    _if = true;//瑙i櫎鎴愬姛
+                                    A31MusicModel.Save();
+                                    break;
+                                }
+                            }
+
+                        }
+                        catch { }
+                    }
+                }
+                catch { }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        MusicMain.loading.Hide();
+                        ///鍙互鎻愮ず瑙i櫎澶辫触;
+                        if (_if)
+                        {
+                            //瑙i櫎鎴愬姛鎵嶅彲浠ュ埛鏂扮晫闈�
+                            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鈥�    {

--
Gitblit v1.8.0