| | |
| | | FileView(dialog, verticalScrolViewLayout, musicInfo); |
| | | |
| | | } |
| | | |
| | | void FileView(Dialog dialog, VerticalScrolViewLayout verticalScrolViewLayout, MusicInfo musicInfo) |
| | | { |
| | | verticalScrolViewLayout.RemoveAll(); |
| | |
| | | TextColor = Color.TextColor, |
| | | TextSize = TextSize.Text14, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = player.Name, |
| | | Text = NamePlayer(player), |
| | | }; |
| | | PlayRow.AddChidren(PlayNameBtn); |
| | | |
| | | |
| | | //选中图标控件 |
| | | Button selectedIconBtn = new Button |
| | |
| | | |
| | | if (playList1.Count <= 1) |
| | | { |
| | | new PublicAssmebly().TipMsgAutoClose("至少选中两个以上播放器", false); |
| | | new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.selectAtLeastTwoPlayers), false); |
| | | return; |
| | | } |
| | | int number = 0; |
| | | foreach (var musin in playList1) |
| | | { |
| | | if (musin.ServerClientType == 1) |
| | | { |
| | | number++; |
| | | } |
| | | } |
| | | if (number >= 2) |
| | | { |
| | | new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.cannotSelectTwoOrMoreMainPlayersToCombine), false); |
| | | //如果都是主播放我就不能组合; |
| | | return; |
| | | } |
| | | ///查询是否已经存在主播放; |
| | |
| | | for (int i = 0; i < playList1.Count; i++) |
| | | { |
| | | var musics = playList1[i]; |
| | | if (musics.A31PlayStatus.playSource == "play") |
| | | if (musics.A31PlayStatus.status == "play") |
| | | { |
| | | playList2.Add(musics); |
| | | } |
| | |
| | | //只有一个播放器在播放,默认为主播发器; |
| | | dialog.Close(); |
| | | var player = playList2[0]; |
| | | Threading(player, playList1); |
| | | MergeThreading(player, playList1); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | Threading(host_Music_If, playList1); |
| | | dialog.Close(); |
| | | MergeThreading(host_Music_If, playList1); |
| | | } |
| | | }; |
| | | } |
| | | /// <summary> |
| | | /// 选中主播放器的界面 |
| | | /// 选中某个音乐为主播放器的界面 |
| | | /// </summary> |
| | | /// <param name="musicList1">显示将要组合的播放器列表</param> |
| | | /// /// <param name="musicList2">显示在播放音乐播放器列表</param> |
| | |
| | | }; |
| | | verticalScrolViewLayout.AddChidren(addFlieRow); |
| | | |
| | | //播放器名称控件 |
| | | Button PlayNameBtn = new Button |
| | | if (player.A31PlayStatus.status == "play") |
| | | { |
| | | X = Application.GetRealWidth(20), |
| | | Y = Application.GetRealHeight(15), |
| | | Width = Application.GetRealWidth(150), |
| | | Height = Application.GetRealHeight(20), |
| | | TextColor = Color.TextColor, |
| | | TextSize = TextSize.Text14, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = player.Name, |
| | | }; |
| | | addFlieRow.AddChidren(PlayNameBtn); |
| | | Button songNameBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(20), |
| | | Y = Application.GetRealHeight(15), |
| | | Width = Application.GetRealWidth(150), |
| | | Height = Application.GetRealHeight(20), |
| | | TextColor = Color.TextColor, |
| | | TextSize = TextSize.Text14, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = player.A31PlayStatus.Title, |
| | | }; |
| | | addFlieRow.AddChidren(songNameBtn); |
| | | |
| | | var wText = songNameBtn.GetTextWidth();//获取文本宽度 |
| | | if (wText > 280) |
| | | { |
| | | songNameBtn.Width = Application.GetRealWidth(280); |
| | | } |
| | | else |
| | | { |
| | | songNameBtn.Width = wText + 5; |
| | | } |
| | | //歌手控件 |
| | | Button singerBtn = new Button |
| | | { |
| | | X = songNameBtn.Right, |
| | | Y = Application.GetRealHeight(15), |
| | | Width = Application.GetRealWidth(280 - songNameBtn.Width), |
| | | Height = Application.GetRealHeight(20), |
| | | TextColor = Color.MusicNoTxetColor, |
| | | TextSize = TextSize.Text12, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = "-" + player.A31PlayStatus.Artist.Trim(), |
| | | }; |
| | | addFlieRow.AddChidren(singerBtn); |
| | | if (wText > 280) |
| | | { |
| | | ///歌名长度小于250才可以显示歌手出来 |
| | | singerBtn.Width = Application.GetRealWidth(0); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //播放器名称控件 |
| | | Button PlayNameBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(20), |
| | | Y = Application.GetRealHeight(15), |
| | | Width = Application.GetRealWidth(150), |
| | | Height = Application.GetRealHeight(20), |
| | | TextColor = Color.TextColor, |
| | | TextSize = TextSize.Text14, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = NamePlayer(player), |
| | | }; |
| | | addFlieRow.AddChidren(PlayNameBtn); |
| | | |
| | | } |
| | | |
| | | //选中图标控件 |
| | | Button selectedIconBtn = new Button |
| | |
| | | { |
| | | if (selectedBtn.Name.ToString() == "No") |
| | | { |
| | | new PublicAssmebly().TipMsgAutoClose("还没选中播放器", false); |
| | | new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.noSelectedPlay), false); |
| | | return; |
| | | } |
| | | dialogF.Close(); |
| | | dialog.Close(); |
| | | |
| | | |
| | | var serverMusic = selectedBtn.Tag as A31MusicModel; |
| | | Threading(serverMusic, musicList1); |
| | | MergeThreading(serverMusic, musicList1); |
| | | }; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 选中解除组合的播放器的界面 |
| | | /// </summary> |
| | | public void DetachPlayMergence(A31MusicModel a31player) |
| | | { |
| | | |
| | | #region |
| | | //主控件 |
| | | Dialog dialog = new Dialog() |
| | | { |
| | | BackgroundColor = Color.PopupBackgroundColor, |
| | | }; |
| | | dialog.Show(); |
| | | //父控件 |
| | | FrameLayout frame = new FrameLayout { }; |
| | | dialog.AddChidren(frame); |
| | | frame.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | dialog.Close(); |
| | | }; |
| | | //白色快父控件 |
| | | FrameLayout dialogFra = new FrameLayout() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(397), |
| | | Width = Application.GetRealWidth(344), |
| | | Height = Application.GetRealHeight(250), |
| | | BackgroundColor = Color.WhiteColor, |
| | | Radius = (uint)Application.GetRealHeight(12), |
| | | }; |
| | | frame.AddChidren(dialogFra); |
| | | //显示头部信息父控件 |
| | | FrameLayout topFra = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(344), |
| | | Height = Application.GetRealHeight(50), |
| | | }; |
| | | dialogFra.AddChidren(topFra); |
| | | //取消控件 |
| | | Button cancelnBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(20), |
| | | Y = Application.GetRealHeight(15), |
| | | Width = Application.GetRealWidth(60), |
| | | Height = Application.GetRealHeight(20), |
| | | TextID = StringId.cancelMusic, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = Color.MusicNoTxetColor, |
| | | TextSize = TextSize.Text14, |
| | | }; |
| | | topFra.AddChidren(cancelnBtn); |
| | | cancelnBtn.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | dialog.Close(); |
| | | }; |
| | | //标题控件 |
| | | Button txetBtn = new Button |
| | | { |
| | | X = cancelnBtn.Right + Application.GetRealWidth(20), |
| | | Y = Application.GetRealHeight(14), |
| | | Width = Application.GetRealWidth(152), |
| | | Height = Application.GetRealHeight(22), |
| | | TextColor = Color.TextColor, |
| | | TextSize = TextSize.Text16, |
| | | TextAlignment = TextAlignment.Center, |
| | | TextID = StringId.checkTheReleasePlayer, |
| | | //Text = "选中解除播放器", |
| | | IsBold = true, |
| | | }; |
| | | topFra.AddChidren(txetBtn); |
| | | |
| | | //确认控件 |
| | | Button confirmBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(344 - 60 - 20), |
| | | Y = Application.GetRealHeight(15), |
| | | Width = Application.GetRealWidth(60), |
| | | Height = Application.GetRealHeight(20), |
| | | TextID = StringId.confirmMusic, |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | TextColor = Color.SelectedColor, |
| | | TextSize = TextSize.Text14, |
| | | }; |
| | | topFra.AddChidren(confirmBtn); |
| | | |
| | | VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout |
| | | { |
| | | Y = Application.GetRealHeight(50), |
| | | Height = dialogFra.Height - Application.GetRealHeight(50), |
| | | Width = Application.GetRealWidth(344), |
| | | }; |
| | | dialogFra.AddChidren(verticalScrolViewLayout); |
| | | |
| | | 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), |
| | | LineColor = Color.WhiteColor, |
| | | SubViewWidth = Application.GetRealWidth(80),//改变编辑控件宽度多少; |
| | | }; |
| | | verticalScrolViewLayout.AddChidren(PlayRow); |
| | | |
| | | |
| | | //播放器名称控件 |
| | | Button PlayNameBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(20), |
| | | Y = Application.GetRealHeight(15), |
| | | Width = Application.GetRealWidth(150), |
| | | Height = Application.GetRealHeight(20), |
| | | TextColor = Color.TextColor, |
| | | TextSize = TextSize.Text14, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = NamePlayer(player), |
| | | }; |
| | | PlayRow.AddChidren(PlayNameBtn); |
| | | |
| | | |
| | | //选中图标控件 |
| | | Button selectedIconBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(303), |
| | | Y = Application.GetRealHeight(11), |
| | | Width = Application.GetMinRealAverage(28), |
| | | Height = Application.GetMinRealAverage(28), |
| | | UnSelectedImagePath = "MusicIcon/noSelectedIcon.png", |
| | | SelectedImagePath = "MusicIcon/selectedIcon.png", |
| | | }; |
| | | PlayRow.AddChidren(selectedIconBtn); |
| | | |
| | | ///加大几点范围 |
| | | Button clickBtn = new Button |
| | | { |
| | | Height = Application.GetRealHeight(50), |
| | | Tag = player.UniqueDeviceName, |
| | | }; |
| | | PlayRow.AddChidren(clickBtn); |
| | | |
| | | clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | clickBtn.IsSelected = !clickBtn.IsSelected; |
| | | selectedIconBtn.IsSelected = clickBtn.IsSelected; |
| | | var uuid = playList2.Find((obj) => obj.UniqueDeviceName == clickBtn.Tag.ToString()); |
| | | if (selectedIconBtn.IsSelected) |
| | | { |
| | | if (uuid == null) |
| | | { |
| | | playList2.Add(player); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (uuid != null) |
| | | { |
| | | playList2.Remove(player); |
| | | } |
| | | } |
| | | }; |
| | | //线 |
| | | Button lineBtn = new Button |
| | | { |
| | | Y = PlayRow.Height - 1, |
| | | X = Application.GetRealWidth(20), |
| | | Width = Application.GetRealWidth(304), |
| | | Height = 1, |
| | | BackgroundColor = Color.LineColor, |
| | | }; |
| | | PlayRow.AddChidren(lineBtn); |
| | | } |
| | | #endregion |
| | | confirmBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (playList1.Count == 0) |
| | | { |
| | | new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.noCheckTheReleasePlayer), false); |
| | | return; |
| | | } |
| | | dialog.Close(); |
| | | RemoveThreading(a31player, playList2); |
| | | }; |
| | | } |
| | | /// <summary> |
| | | /// 发送组合命令逻辑处理的方法 |
| | | /// </summary> |
| | | /// <param name="serverMusic">主播放器</param> |
| | | /// <param name="musicList1"></param> |
| | | void Threading(A31MusicModel serverMusic, List<A31MusicModel> musicList1) |
| | | void MergeThreading(A31MusicModel serverMusic, List<A31MusicModel> musicList1) |
| | | { |
| | | MusicMain.loading.Start("配置中..."); |
| | | MusicMain.loading.Start(Language.StringByID(StringId.inConfiguration)); |
| | | bool _if = false; |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | |
| | | //过滤掉主播放器; |
| | | continue; |
| | | } |
| | | System.Threading.Thread.Sleep(1000);//等待一秒再发数据 |
| | | 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)) |
| | | { |
| | |
| | | |
| | | } |
| | | } |
| | | System.Threading.Thread.Sleep(1000);//等待1秒再发数据 |
| | | } |
| | | DateTime dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < 12 * 1000) |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < 15 * 1000) |
| | | { |
| | | System.Threading.Thread.Sleep(1000); |
| | | try |
| | |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 分开组合的播放器的界面 |
| | | /// 解除组合命令逻辑处理的方法 |
| | | /// </summary> |
| | | public void DetachPlayMergence(A31MusicModel a31player) |
| | | /// <param name="a31player">主播放器</param> |
| | | /// <param name="playList1"></param> |
| | | void RemoveThreading(A31MusicModel a31player, List<A31MusicModel> playList1) |
| | | { |
| | | MusicMain.loading.Start(Language.StringByID(StringId.lifting)); |
| | | var slaveList = new List<Slave>(); |
| | | slaveList.AddRange(a31player.Slave.slave_list); |
| | | // bool host_If = false; //表示是否显示解除的播放 |
| | | bool _if = false; |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | var play_If = playList1.Find((obj) => obj.UniqueDeviceName == a31player.UniqueDeviceName); |
| | | if (play_If == null) |
| | | { |
| | | //子音箱与主音箱断开的命令 |
| | | 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 |
| | | { |
| | | //解散组的命令 |
| | | 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 (tmepSlaves.slave_list.Count == 0) |
| | | { |
| | | |
| | | var host_music = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == a31player.UniqueDeviceName); |
| | | if (host_music != null) |
| | | { |
| | | host_music.ServerClientType = 0;//解除主从关系 |
| | | 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;//解除主从关系 |
| | | music.IsCanShow = true;//允许显示 |
| | | music.IsOnLine = false;//先不允许读取 |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (int b = 0; b < tmepSlaves.slave_list.Count; b++) |
| | | { |
| | | var uuid = tmepSlaves.slave_list[b].uuid.Replace("uuid:", ""); |
| | | var music = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == uuid); |
| | | if (music != null) |
| | | { |
| | | music.ServerClientType = 0;//解除主从关系 |
| | | 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;//解除成功 |
| | | 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; |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | public string NamePlayer(A31MusicModel a31player) |
| | | { |
| | | if (a31player.ServerClientType == 1) |
| | | { |
| | | return a31player.MainPlayName; |
| | | } |
| | | else |
| | | { |
| | | return a31player.Name; |
| | | } |
| | | } |
| | | |
| | | List<A31MusicModel> volumePlayList = new List<A31MusicModel>(); |
| | | A31MusicModel currVolumePlay = null;//当前的播放器 |
| | | int startVolume = 0;//之前的音量 |
| | | int endVolume = 0;//现在的音量 |
| | | /// <summary> |
| | | /// 播放器音量的界面 |
| | | /// </summary> |
| | | /// <param name="a31player">主播放器</param> |
| | | public void PlayerVolumeView(A31MusicModel a31player) |
| | | { |
| | | #region |
| | | //主控件 |
| | | Dialog dialog = new Dialog() |
| | | { |
| | | BackgroundColor = Color.PopupBackgroundColor, |
| | | }; |
| | | dialog.Show(); |
| | | Dialog volumedialog = new Dialog(); |
| | | volumedialog.Show(); |
| | | //父控件 |
| | | FrameLayout frame = new FrameLayout { }; |
| | | dialog.AddChidren(frame); |
| | | volumedialog.AddChidren(frame); |
| | | frame.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | dialog.Close(); |
| | | volumedialog.Close(); |
| | | if (updateVolumeThread != null) |
| | | { |
| | | try |
| | | { |
| | | if (updateVolumeThread.IsAlive) |
| | | { |
| | | updateVolumeThread.Abort(); |
| | | } |
| | | } |
| | | catch { } |
| | | } |
| | | }; |
| | | //白色快父控件 |
| | | FrameLayout dialogFra = new FrameLayout() |
| | |
| | | FrameLayout topFra = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(344), |
| | | Height = Application.GetRealHeight(50), |
| | | Height = Application.GetRealHeight(58), |
| | | }; |
| | | dialogFra.AddChidren(topFra); |
| | | //取消控件 |
| | |
| | | topFra.AddChidren(cancelnBtn); |
| | | cancelnBtn.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | dialog.Close(); |
| | | volumedialog.Close(); |
| | | if (updateVolumeThread != null) |
| | | { |
| | | try |
| | | { |
| | | if (updateVolumeThread.IsAlive) |
| | | { |
| | | updateVolumeThread.Abort(); |
| | | } |
| | | } |
| | | catch { } |
| | | } |
| | | }; |
| | | //标题控件 |
| | | Button txetBtn = new Button |
| | |
| | | TextColor = Color.TextColor, |
| | | TextSize = TextSize.Text16, |
| | | TextAlignment = TextAlignment.Center, |
| | | //TextID = StringId.selectedMergence, |
| | | TextID = StringId.volumeAdjustment, |
| | | IsBold = true, |
| | | Text= a31player.Name, |
| | | }; |
| | | topFra.AddChidren(txetBtn); |
| | | |
| | | //确认控件 |
| | | Button confirmBtn = new Button |
| | | { |
| | |
| | | TextSize = TextSize.Text14, |
| | | }; |
| | | topFra.AddChidren(confirmBtn); |
| | | |
| | | VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout |
| | | confirmBtn.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | Y = Application.GetRealHeight(50), |
| | | Height = dialogFra.Height - Application.GetRealHeight(50), |
| | | Width = Application.GetRealWidth(344), |
| | | volumedialog.Close(); |
| | | if (updateVolumeThread != null) |
| | | { |
| | | try |
| | | { |
| | | if (updateVolumeThread.IsAlive) |
| | | { |
| | | updateVolumeThread.Abort(); |
| | | } |
| | | } |
| | | catch { } |
| | | } |
| | | }; |
| | | dialogFra.AddChidren(verticalScrolViewLayout); |
| | | |
| | | var playList1 = new List<A31MusicModel>(); |
| | | playList1.Add(a31player); |
| | | VerticalScrolViewLayout volumeViewLayout = new VerticalScrolViewLayout |
| | | { |
| | | Y = Application.GetRealHeight(58), |
| | | Height = dialogFra.Height - Application.GetRealHeight(58), |
| | | Width = Application.GetRealWidth(343), |
| | | }; |
| | | dialogFra.AddChidren(volumeViewLayout); |
| | | volumePlayList.Clear(); |
| | | 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); |
| | | music_If.ServerClientType = -1; |
| | | music_If.A31PlayStatus.vol = slave.volume; |
| | | volumePlayList.Add(music_If); |
| | | } |
| | | } |
| | | volumePlayList.Add(a31player); |
| | | |
| | | |
| | | var playList2 = new List<A31MusicModel>(); |
| | | for (int i = 0; i < playList1.Count; i++) |
| | | for (int i = 0; i < volumePlayList.Count; i++) |
| | | { |
| | | var player = playList1[i]; |
| | | RowLayout PlayRow = new RowLayout |
| | | var player = volumePlayList[i]; |
| | | FrameLayout volumeFra = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(50), |
| | | LineColor = Color.WhiteColor, |
| | | SubViewWidth = Application.GetRealWidth(80),//改变编辑控件宽度多少; |
| | | Height = Application.GetRealHeight(64), |
| | | }; |
| | | verticalScrolViewLayout.AddChidren(PlayRow); |
| | | |
| | | |
| | | //播放器名称控件 |
| | | Button PlayNameBtn = new Button |
| | | volumeViewLayout.AddChidren(volumeFra); |
| | | Button volumeTextBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(20), |
| | | Y = Application.GetRealHeight(15), |
| | | Width = Application.GetRealWidth(150), |
| | | Height = Application.GetRealHeight(20), |
| | | TextColor = Color.TextColor, |
| | | TextSize = TextSize.Text14, |
| | | X = Application.GetRealWidth(28), |
| | | Y = Application.GetRealHeight(8), |
| | | Width = Application.GetRealWidth(200), |
| | | Height = Application.GetRealHeight(14), |
| | | TextColor = Color.MusicNoTxetColor, |
| | | TextSize = TextSize.Text10, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = player.Name, |
| | | |
| | | }; |
| | | PlayRow.AddChidren(PlayNameBtn); |
| | | |
| | | |
| | | //选中图标控件 |
| | | Button selectedIconBtn = new Button |
| | | volumeFra.AddChidren(volumeTextBtn); |
| | | if (player.ServerClientType == -1) |
| | | { |
| | | X = Application.GetRealWidth(303), |
| | | Y = Application.GetRealHeight(11), |
| | | Width = Application.GetMinRealAverage(28), |
| | | Height = Application.GetMinRealAverage(28), |
| | | UnSelectedImagePath = "MusicIcon/noSelectedIcon.png", |
| | | SelectedImagePath = "MusicIcon/selectedIcon.png", |
| | | volumeTextBtn.Text = player.Name + Language.StringByID(StringId.volumeMusic); |
| | | } |
| | | else if (player.ServerClientType == 1) |
| | | { |
| | | volumeTextBtn.Text = Language.StringByID(StringId.totalVolume); |
| | | } |
| | | |
| | | DiyImageSeekBar volSeekBar = new DiyImageSeekBar |
| | | { |
| | | Y = Application.GetRealHeight(12), |
| | | X = Application.GetRealWidth(28), |
| | | Width = Application.GetRealWidth(240), |
| | | Height = Application.GetRealHeight(54),//进度条父控件背景高度 |
| | | IsProgressTextShow = false,//显示百分比 |
| | | IsClickable = true,//进度条是否滑动 |
| | | ProgressBarColor = Color.SelectedColor,//选中进度条颜色 |
| | | ThumbImagePath = "MusicIcon/progressIcon.png",//进度条按钮图标 |
| | | ThumbImageHeight = Application.GetMinRealAverage(54),//进度条按钮图标的高度(默认正方形:宽和高一样) |
| | | SeekBarViewHeight = Application.GetMinRealAverage(8),//进度条的高度 |
| | | Progress = int.Parse(player.A31PlayStatus.vol), |
| | | //ProgressChangeDelayTime= |
| | | }; |
| | | PlayRow.AddChidren(selectedIconBtn); |
| | | volumeFra.AddChidren(volSeekBar); |
| | | |
| | | ///加大几点范围 |
| | | Button clickBtn = new Button |
| | | Button valueBtn = new Button |
| | | { |
| | | Height = Application.GetRealHeight(50), |
| | | Tag = player.UniqueDeviceName, |
| | | X = Application.GetRealWidth(289), |
| | | Y = Application.GetRealHeight(31), |
| | | Width = Application.GetRealWidth(26), |
| | | Height = Application.GetRealHeight(17), |
| | | TextColor = Color.MusicNoTxetColor, |
| | | TextSize = TextSize.Text12, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = player.A31PlayStatus.vol + "%", |
| | | }; |
| | | PlayRow.AddChidren(clickBtn); |
| | | volumeFra.AddChidren(valueBtn); |
| | | |
| | | clickBtn.MouseUpEventHandler += (sender, e) => |
| | | |
| | | ///音量进度条点击事件 |
| | | EventHandler<int> progressClick = (sender, e) => |
| | | { |
| | | clickBtn.IsSelected = !clickBtn.IsSelected; |
| | | selectedIconBtn.IsSelected = clickBtn.IsSelected; |
| | | var uuid = playList2.Find((obj) => obj.UniqueDeviceName== clickBtn.Tag.ToString()); |
| | | if (selectedIconBtn.IsSelected) |
| | | |
| | | if (currVolumePlay == null || (currVolumePlay != null && currVolumePlay.UniqueDeviceName != player.UniqueDeviceName)) |
| | | { |
| | | if (uuid == null) |
| | | { |
| | | playList2.Add(player); |
| | | } |
| | | currVolumePlay = player; |
| | | } |
| | | else |
| | | endVolume = e; |
| | | if (player.ServerClientType == -1) |
| | | { |
| | | if (uuid != null) |
| | | valueBtn.Text = volSeekBar.Progress + "%"; |
| | | //SendMethod.ControlVolume(volSeekBar.Progress, player); |
| | | } |
| | | else if (player.ServerClientType == 1) |
| | | { |
| | | for (int j = 0; j < volumePlayList.Count; j++) |
| | | { |
| | | playList2.Remove(player); |
| | | var music = volumePlayList[j]; |
| | | var frameLayout = (FrameLayout)volumeViewLayout.GetChildren(j); |
| | | var diyImageSeekBar = (DiyImageSeekBar)frameLayout.GetChildren(1); |
| | | var button = (Button)frameLayout.GetChildren(2); |
| | | diyImageSeekBar.Progress = volSeekBar.Progress; |
| | | button.Text = volSeekBar.Progress + "%"; |
| | | //SendMethod.ControlVolume(volSeekBar.Progress, music); |
| | | } |
| | | } |
| | | }; |
| | | //线 |
| | | Button lineBtn = new Button |
| | | { |
| | | Y = PlayRow.Height - 1, |
| | | X = Application.GetRealWidth(20), |
| | | Width = Application.GetRealWidth(304), |
| | | Height = 1, |
| | | BackgroundColor = Color.LineColor, |
| | | }; |
| | | PlayRow.AddChidren(lineBtn); |
| | | volSeekBar.OnProgressChangedEvent += progressClick; |
| | | volSeekBar.OnStopTrackingTouchEvent += progressClick; |
| | | } |
| | | #endregion |
| | | confirmBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (playList1.Count == 0) |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 定时音量并且发送命令 |
| | | /// </summary> |
| | | System.Threading.Thread updateVolumeThread; |
| | | public void UpdateVolume() |
| | | { |
| | | if (updateVolumeThread != null) { |
| | | try |
| | | { |
| | | new PublicAssmebly().TipMsgAutoClose("还没有选择解除组播放器", false); |
| | | return; |
| | | if (updateVolumeThread.IsAlive) { |
| | | updateVolumeThread.Abort(); |
| | | } |
| | | } |
| | | dialog.Close(); |
| | | |
| | | MusicMain.loading.Start("解除中..."); |
| | | bool _if = false; |
| | | System.Threading.Tasks.Task.Run(() => |
| | | catch { } |
| | | } |
| | | updateVolumeThread = new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | try |
| | | while (true) |
| | | { |
| | | var play_If = playList1.Find((obj) => obj.UniqueDeviceName == a31player.UniqueDeviceName); |
| | | if (play_If == null) |
| | | System.Threading.Thread.Sleep(500); |
| | | if (startVolume == endVolume || currVolumePlay == null) |
| | | { |
| | | //子音箱与主音箱断开的命令 |
| | | 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)) |
| | | { |
| | | continue; |
| | | } |
| | | startVolume = endVolume; |
| | | |
| | | } |
| | | } |
| | | ///每解除一个播放器需要等待3秒 |
| | | System.Threading.Thread.Sleep(3000);//等待3秒再发数据 |
| | | if (currVolumePlay.ServerClientType == -1) |
| | | { |
| | | SendMethod.ControlVolume(endVolume, currVolumePlay); |
| | | } |
| | | else if (currVolumePlay.ServerClientType == 1) |
| | | { |
| | | for (int j = 0; j < volumePlayList.Count; j++) |
| | | { |
| | | var music = volumePlayList[j]; |
| | | SendMethod.ControlVolume(endVolume, music); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //解散组的命令 |
| | | 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 && tmepSlaves.slave_list.Count == 0) |
| | | { |
| | | _if = true;//解除成功 |
| | | 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; |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | }; |
| | | } |
| | | } |
| | | catch { } |
| | | }) |
| | | { IsBackground = true }; |
| | | updateVolumeThread.Start(); |
| | | } |
| | | |
| | | } |
| | | [System.Serializable] |
| | | public class A31Wifi
{ |