| | |
| | | //public MusicListViewMain() { |
| | | // Frame = this; |
| | | //} |
| | | public MusicMain() |
| | | { |
| | | Tag = "MusicMain"; |
| | | } |
| | | public override void RemoveFromParent() |
| | | { |
| | | base.RemoveFromParent(); |
| | |
| | | /// <summary> |
| | | /// 显示加载界面 |
| | | /// </summary> |
| | | public static Loading Loading = new Loading(); |
| | | public static Loading loading = new Loading(); |
| | | VerticalRefreshLayout verticalRefresh; |
| | | |
| | | public void Show() |
| | |
| | | |
| | | verticalRefresh.BeginHeaderRefreshingAction += () => |
| | | { |
| | | SeachMusic(); |
| | | verticalRefresh.EndHeaderRefreshing(); |
| | | SeachMusic(false); |
| | | |
| | | }; |
| | | this.AddChidren(Loading); |
| | | this.AddChidren(loading); |
| | | |
| | | if (A31MusicModel.A31MusicModelList.Count == 0) |
| | | { |
| | |
| | | else |
| | | { |
| | | clearA31Threads(); |
| | | verticalRefresh.RemoveAll(); |
| | | //verticalRefresh.RemoveAll(); |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | | { |
| | | var a31player = A31MusicModel.A31MusicModelList[i]; |
| | |
| | | if (!a31player.IsCanShow) |
| | | { |
| | | continue; |
| | | } |
| | | if (A31MusicModel.A31MusicModelList.Count - 1 == i) |
| | | { |
| | | a31player.IsEnd = true; |
| | | } |
| | | else |
| | | { |
| | | a31player.IsEnd = false; |
| | | } |
| | | ///加载界面时默认不在线 |
| | | ///这里标记是为了不读取不在线播放器状态 |
| | |
| | | if (obj == null) |
| | | { |
| | | ///这里要读取主从关系 |
| | | // readServerOrClientMode(false); |
| | | readServerOrClientMode(); |
| | | A31MusicModel.Save(); |
| | | return; |
| | | } |
| | |
| | | if (Yes) |
| | | { |
| | | //为了第一次进来log一下; |
| | | Loading.Start(); |
| | | loading.Start(); |
| | | } |
| | | SendMethod.Seach((obj) => |
| | | { |
| | | if (obj == null) |
| | | { |
| | | //readServerOrClientMode(true); |
| | | readServerOrClientMode(); |
| | | A31MusicModel.Save(); |
| | | if (!Yes) |
| | | { |
| | | ///等待跑完在关闭 |
| | | verticalRefresh.EndHeaderRefreshing(); |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (Yes) |
| | | { |
| | | //为了第一次进来log一下; |
| | | Loading.Hide(); |
| | | loading.Hide(); |
| | | } |
| | | verticalRefresh.RemoveAll(); |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | |
| | | { |
| | | continue; |
| | | } |
| | | if (A31MusicModel.A31MusicModelList.Count - 1 == i) |
| | | { |
| | | a31player.IsEnd = true; |
| | | } |
| | | else |
| | | { |
| | | a31player.IsEnd = false; |
| | | } |
| | | MusicListView(a31player); |
| | | } |
| | | |
| | | }); |
| | | return; |
| | | } |
| | |
| | | musicView.View(verticalRefresh); |
| | | musicView.singerBtn.Text = a31player.A31PlayStatus.Artist; |
| | | musicView.songNameBtn.Text = a31player.A31PlayStatus.Title; |
| | | musicView.musicNameBtn.Text = a31player.Name; |
| | | musicView.musicNameBtn.Text = new View.DialogView { }.NamePlayer(a31player); |
| | | musicView.regionBtn.TextID = StringId.region; |
| | | if (a31player.A31PlayStatus.status == "play") |
| | | { |
| | | musicView.playBtn.IsSelected = true; |
| | | if (a31player.IsEnd) { |
| | | musicView.muiscFl.Height =Application.GetRealHeight(12 + 139 + 12); |
| | | } |
| | | else |
| | | EventHandler<MouseEventArgs> clickMergence = (sender, e) => |
| | | { |
| | | musicView.playBtn.IsSelected = false; |
| | | } |
| | | EventHandler<MouseEventArgs> clickPlay = (sender, e) => |
| | | { |
| | | A31MusicModel.Current = a31player;//当前播放器 |
| | | var a31PlayMusicPage = new A31PlayMusicPage(); |
| | | MainPage.BasePageView.AddChidren(a31PlayMusicPage); |
| | | a31PlayMusicPage.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | if (a31player.ServerClientType == 0) |
| | | { |
| | | new View.DialogView { }.PlayMergence(); |
| | | } |
| | | else if (a31player.ServerClientType == 1) |
| | | { |
| | | new View.DialogView { }.DetachPlayMergence(a31player); |
| | | |
| | | } |
| | | }; |
| | | musicView.mergeBjBtn.MouseUpEventHandler += clickMergence; |
| | | musicView.mergeBtn.MouseUpEventHandler += clickMergence; |
| | | musicView.mergeIconBtn.MouseUpEventHandler += clickMergence; |
| | | |
| | | musicView.singerBtn.MouseUpEventHandler += clickPlay; |
| | | musicView.songNameBtn.MouseUpEventHandler += clickPlay; |
| | | musicView.musicNameBtn.MouseUpEventHandler += clickPlay; |
| | | musicView.regionBtn.MouseUpEventHandler += clickPlay; |
| | | |
| | | musicView.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | A31MusicModel.Current = a31player;//当前播放器 |
| | | var a31PlayMusicPage = new A31PlayMusicPage(); |
| | | MainPage.BasePageView.AddChidren(a31PlayMusicPage); |
| | | a31PlayMusicPage.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | ///上一曲点击事件 |
| | | musicView.prevBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | musicView.prevBtn.IsSelected = true; |
| | | SendMethod.Previous(); |
| | | SendMethod.Previous(a31player); |
| | | }; |
| | | musicView.prevBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | if (musicView.playBtn.IsSelected) |
| | | { |
| | | musicView.playBtn.IsSelected = false; |
| | | SendMethod.Pause(); |
| | | A31MusicModel.Current.A31PlayStatus.status = "pause"; |
| | | SendMethod.Pause(a31player); |
| | | a31player.A31PlayStatus.status = "pause"; |
| | | } |
| | | else |
| | | { |
| | | musicView.playBtn.IsSelected = true; |
| | | SendMethod.Play(); |
| | | A31MusicModel.Current.A31PlayStatus.status = "play"; |
| | | SendMethod.Play(a31player); |
| | | a31player.A31PlayStatus.status = "play"; |
| | | } |
| | | }; |
| | | ///下一曲点击事件 |
| | | musicView.nextBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | musicView.nextBtn.IsSelected = true; |
| | | SendMethod.Next(); |
| | | SendMethod.Next(a31player); |
| | | }; |
| | | musicView.nextBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | { |
| | | musicView.singerBtn.Text = a31player.A31PlayStatus.Artist; |
| | | musicView.songNameBtn.Text = a31player.A31PlayStatus.Title; |
| | | musicView.musicNameBtn.Text = a31player.Name; |
| | | musicView.musicNameBtn.Text = new View.DialogView { }.NamePlayer(a31player); |
| | | if (a31player.A31PlayStatus.status == "play") |
| | | { |
| | | musicView.playBtn.IsSelected = true; |
| | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取主从关系 |
| | | /// </summary> |
| | | void readServerOrClientMode() |
| | | { |
| | | try |
| | | { |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | | { |
| | | var a31player = A31MusicModel.A31MusicModelList[i]; |
| | | if (!a31player.IsOnLine) |
| | | { |
| | | continue; |
| | | } |
| | | try |
| | | { |
| | | a31player.ServerClientType = 0; |
| | | var result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); |
| | | if (result == null && result == "Failed") |
| | | { |
| | | result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); |
| | | } |
| | | if (result != null && result != "Failed") |
| | | { |
| | | a31player.Slave = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var d = e.Message; |
| | | } |
| | | } |
| | | |
| | | //分析主从关系 |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | | { |
| | | var a31player = A31MusicModel.A31MusicModelList[i]; |
| | | if (!a31player.IsOnLine) |
| | | { |
| | | continue; |
| | | } |
| | | try |
| | | { |
| | | if (a31player.Slave != null && "0" != a31player.Slave.slaves) |
| | | { |
| | | a31player.ServerClientType = 1;//主的 |
| | | string str = a31player.Name; |
| | | for (int j = 0; j < a31player.Slave.slave_list.Count; j++) |
| | | { |
| | | |
| | | var slave = a31player.Slave.slave_list[j]; |
| | | str = str + "+" + slave.name; |
| | | var tempA31Player = A31MusicModel.A31MusicModelList.Find((obj) => slave.uuid.Replace("uuid:", "") == obj.UniqueDeviceName); |
| | | if (tempA31Player == null) |
| | | { |
| | | A31MusicModel.A31MusicModelList.Add(new A31MusicModel |
| | | { |
| | | ServerClientType = -1,//从的 |
| | | IPAddress = slave.ip, |
| | | MainPlayIP = a31player.IPAddress, |
| | | UniqueDeviceName = slave.uuid.Replace("uuid:", ""), |
| | | Name = slave.name, |
| | | IsCanShow = false, |
| | | IsOnLine = false,//true作用为了读取从播放器的音量 |
| | | }); |
| | | } |
| | | //如果找到就更新为从的 |
| | | else |
| | | { |
| | | tempA31Player.ServerClientType = -1;//从的 |
| | | tempA31Player.IPAddress = slave.ip; |
| | | tempA31Player.MainPlayIP = a31player.IPAddress; |
| | | tempA31Player.Name = slave.name; |
| | | tempA31Player.UniqueDeviceName = slave.uuid.Replace("uuid:", ""); |
| | | tempA31Player.IsCanShow = false; |
| | | tempA31Player.IsOnLine = false;//true作用为了读取从播放器的音量 |
| | | |
| | | } |
| | | } |
| | | a31player.MainPlayName = str; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var ss = e.Message; |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch { } |
| | | } |
| | | |
| | | } |
| | | |