| | |
| | | using Shared.IO; |
| | | using System.Net; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.UI.UI2.FuntionControlView.Music; |
| | | |
| | | namespace HDL_ON.UI.Music |
| | | { |
| | | public class MusicMain : FrameLayout |
| | | { |
| | | private static MusicMain m_MusicMain = null; |
| | | public static MusicMain mMusicMain |
| | | { |
| | | get |
| | | { |
| | | if (m_MusicMain == null) |
| | | { |
| | | m_MusicMain = new MusicMain(); |
| | | } |
| | | return m_MusicMain; |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// MusicMain对象构造函数 |
| | | /// </summary> |
| | | public MusicMain() |
| | | { |
| | | Tag = "MusicMain"; |
| | | //进来音乐列表界面先移除之前线程; |
| | | A31MusicModel.RemoveListThread(); |
| | | } |
| | | /// <summary> |
| | | /// 重写RemoveFromParent方法 |
| | |
| | | { |
| | | base.RemoveFromParent(); |
| | | clearA31Threads(); |
| | | A31MusicModel.ReadMusicStates();//进来没有音乐被收藏过,退出有音乐被收藏过 |
| | | //进来没有音乐被收藏过,退出有音乐被收藏过 |
| | | //A31MusicModel.ReadMusicStates(); |
| | | } |
| | | /// <summary> |
| | | /// 创建线程列表 |
| | |
| | | { |
| | | Y = topView.fLayout.Bottom, |
| | | Height = Application.GetRealHeight(H_W.H - H_W.T_Height), |
| | | Name = "verticalRefresh", |
| | | }; |
| | | this.AddChidren(verticalRefresh); |
| | | #endregion |
| | |
| | | { |
| | | verticalRefresh.RemoveAll(); |
| | | |
| | | var musicListFunction = SendMethod.sendMethod.GetMusicList; |
| | | var musicListFunction = SendMethod.mMethod.GetMusicList; |
| | | for (int i = 0; i < musicListFunction.Count; i++) |
| | | { |
| | | var function = musicListFunction[i]; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | | { |
| | | |
| | | var a31player = A31MusicModel.A31MusicModelList[i]; |
| | | MusicListView(a31player); |
| | | if (a31player.functionMusic.online == false) |
| | | { |
| | | //不在线不显示 |
| | | continue; |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | MusicListView(a31player); |
| | | }); |
| | | } |
| | | ///进来读一次音乐播放器状态 |
| | | for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) |
| | | { |
| | | |
| | | var a31player = A31MusicModel.A31MusicModelList[i]; |
| | | if (a31player.functionMusic.online == false) |
| | | { |
| | | //不在线不读取 |
| | | continue; |
| | | } |
| | | //发送读取音乐播放器状态线程 |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | SendMethod.mMethod.RefreshDeviceStatus(new List<string> { a31player.functionMusic.deviceId }); |
| | | System.Threading.Thread.Sleep(500); |
| | | } |
| | | catch { } |
| | | |
| | | }); |
| | | } |
| | | |
| | | }); |
| | |
| | | /// <summary> |
| | | /// 显示音乐列表的方法 |
| | | /// </summary> |
| | | void MusicListView(A31MusicModel player) |
| | | void MusicListView(A31MusicModel player) |
| | | { |
| | | musicView.View(verticalRefresh); |
| | | musicView.singerBtn.Text = player.functionMusic.GetAttrState("song_name"); |
| | | musicView.songNameBtn.Text = player.functionMusic.GetAttrState("song_name"); |
| | | musicView.ViewAddChidren(verticalRefresh); |
| | | musicView.muiscFl.Tag = player.functionMusic;//多个音乐播放器更新状态要用到 |
| | | musicView.singerBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name); |
| | | musicView.songNameBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name); |
| | | musicView.musicNameBtn.Text = player.functionMusic.name; |
| | | //if (player.IsEnd) |
| | | //{ |
| | | // musicView.muiscFl.Height = Application.GetRealHeight(12 + 139 + 12); |
| | | //} |
| | | |
| | | ///收藏事件 |
| | | musicView.collectIconBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | musicView.collectIconBtn.IsSelected = !musicView.collectIconBtn.IsSelected; |
| | |
| | | } |
| | | }; |
| | | |
| | | EventHandler<MouseEventArgs> clickMergence = (sender, e) => |
| | | { |
| | | //if (player.ServerClientType == 0) |
| | | //{ |
| | | // new View.DialogView { }.PlayMergence(player); |
| | | //} |
| | | //else if (player.ServerClientType == 1) |
| | | //{ |
| | | // new View.DialogView { }.DetachPlayMergence(player); |
| | | //} |
| | | }; |
| | | musicView.mergeBjBtn.MouseUpEventHandler += clickMergence; |
| | | musicView.mergeBtn.MouseUpEventHandler += clickMergence; |
| | | musicView.mergeIconBtn.MouseUpEventHandler += clickMergence; |
| | | |
| | | ///进入音乐主页事件 |
| | | EventHandler<MouseEventArgs> clickPlayView = (sender, e) => |
| | | { |
| | | |
| | |
| | | musicView.prevBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | musicView.prevBtn.IsSelected = true; |
| | | player.functionMusic.SetAttrState("song_step", "up"); |
| | | player.functionMusic.SetAttrState(KeyProperty.song_step, ValueProperty.up); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_step", "up"); |
| | | SendMethod.sendMethod.SendControlCommand(player.functionMusic, dic); |
| | | dic.Add(KeyProperty.song_step, ValueProperty.up); |
| | | SendMethod.mMethod.SendControlCommand(player.functionMusic, dic); |
| | | }; |
| | | musicView.prevBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | ///暂停/播放点击事件 |
| | | musicView.playBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | string status = "off"; |
| | | string status = ValueProperty.off; |
| | | if (musicView.playBtn.IsSelected) |
| | | { |
| | | musicView.playBtn.IsSelected = false; |
| | | status = "off"; |
| | | status = ValueProperty.off; |
| | | } |
| | | else |
| | | { |
| | | musicView.playBtn.IsSelected = true; |
| | | status = "on"; |
| | | status = ValueProperty.on; |
| | | } |
| | | player.functionMusic.SetAttrState("on_off", status); |
| | | player.functionMusic.SetAttrState(KeyProperty.on_off, status); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("on_off", status); |
| | | SendMethod.sendMethod.SendControlCommand(player.functionMusic, dic); |
| | | dic.Add(KeyProperty.on_off, status); |
| | | SendMethod.mMethod.SendControlCommand(player.functionMusic, dic); |
| | | }; |
| | | ///下一曲点击事件 |
| | | musicView.nextBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | musicView.nextBtn.IsSelected = true; |
| | | player.functionMusic.SetAttrState("song_step", "down"); |
| | | player.functionMusic.SetAttrState(KeyProperty.song_step, ValueProperty.down); |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | dic.Add("song_step", "down"); |
| | | SendMethod.sendMethod.SendControlCommand(player.functionMusic, dic); |
| | | dic.Add(KeyProperty.song_step, ValueProperty.down); |
| | | SendMethod.mMethod.SendControlCommand(player.functionMusic, dic); |
| | | }; |
| | | musicView.nextBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | musicView.nextBtn.IsSelected = false; |
| | | }; |
| | | |
| | | //更新状态线程 |
| | | var musicThread = new System.Threading.Thread(() => |
| | | { |
| | | while (true) |
| | | { |
| | | System.Threading.Thread.Sleep(1000); |
| | | if (!player.functionMusic.online) |
| | | { |
| | | ///不在线不读状态 |
| | | continue; |
| | | } |
| | | //SendMethod.ReadStatus(player); |
| | | SendMethod.sendMethod.RefreshDeviceStatus(player.functionMusic,new List<string> { player.functionMusic.deviceId }); |
| | | |
| | | SendMethod.mMethod.GetDeviceStatus(ref player, new List<string> { player.functionMusic.deviceId }, player.functionMusic.sid); |
| | | System.Threading.Thread.Sleep(1000); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | musicView.singerBtn.Text = player.functionMusic.GetAttrState("song_name"); |
| | | musicView.songNameBtn.Text = player.functionMusic.GetAttrState("song_name"); |
| | | musicView.singerBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name); |
| | | musicView.songNameBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name); |
| | | musicView.musicNameBtn.Text = player.functionMusic.name; |
| | | if (player.A31PlayStatus.status == "play") |
| | | if (player.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on) |
| | | { |
| | | musicView.playBtn.IsSelected = true; |
| | | } |
| | |
| | | musicView.playBtn.IsSelected = false; |
| | | } |
| | | musicView.regionBtn.Text = player.functionMusic.GetRoomListName(); |
| | | if (player.ServerClientType == 1) |
| | | |
| | | if (player.functionMusic.collect) |
| | | { |
| | | if (player.MainPlayCollection) |
| | | { |
| | | musicView.collectIconBtn.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | musicView.collectIconBtn.IsSelected = false; |
| | | } |
| | | musicView.collectIconBtn.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | if (player.functionMusic.collect) |
| | | { |
| | | musicView.collectIconBtn.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | musicView.collectIconBtn.IsSelected = false; |
| | | } |
| | | musicView.collectIconBtn.IsSelected = false; |
| | | } |
| | | }); |
| | | } |
| | |
| | | ///指定刷新界面 |
| | | /// </summary> |
| | | /// <param name="strView">判断字符</param> |
| | | public void RefreshView(string strView) |
| | | public void RefreshView(AlinkStatusData alinkStatusData) |
| | | { |
| | | if (alinkStatusData == null || alinkStatusData.status.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | |
| | | for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) |
| | | for (int a =0; a < MainPage.BasePageView.ChildrenCount; a++) |
| | | { |
| | | var view = MainPage.BasePageView.GetChildren(i); |
| | | if (strView == view.Tag.ToString()) |
| | | var view = MainPage.BasePageView.GetChildren(a); |
| | | if (view.GetType() == typeof(MusicMain)) |
| | | { |
| | | if (view.GetType() == typeof(MusicMain)) |
| | | var musicMain = view as MusicMain; |
| | | if (musicMain != null) |
| | | { |
| | | //musicView.singerBtn.Text = player.A31PlayStatus.Artist; |
| | | //musicView.songNameBtn.Text = player.A31PlayStatus.Title; |
| | | //musicView.musicNameBtn.Text = new View.DialogView { }.NamePlayer(player); |
| | | //if (player.A31PlayStatus.status == "play") |
| | | //{ |
| | | // musicView.playBtn.IsSelected = true; |
| | | //} |
| | | //else |
| | | //{ |
| | | // musicView.playBtn.IsSelected = false; |
| | | //} |
| | | //musicView.regionBtn.Text = player.GetRoomListName(); |
| | | //if (player.ServerClientType == 1) |
| | | //{ |
| | | // if (player.MainPlayCollection) |
| | | // { |
| | | // musicView.collectIconBtn.IsSelected = true; |
| | | // } |
| | | // else |
| | | // { |
| | | // musicView.collectIconBtn.IsSelected = false; |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | // if (player.collect) |
| | | // { |
| | | // musicView.collectIconBtn.IsSelected = true; |
| | | // } |
| | | // else |
| | | // { |
| | | // musicView.collectIconBtn.IsSelected = false; |
| | | // } |
| | | //} |
| | | } |
| | | } |
| | | for (int b = 0; b < musicMain.ChildrenCount; b++) |
| | | { |
| | | var view1 = musicMain.GetChildren(b); |
| | | if (view1.GetType() == typeof(VerticalRefreshLayout)) |
| | | { |
| | | var vv = view1 as VerticalRefreshLayout; |
| | | if (vv != null && vv.Name == "verticalRefresh") |
| | | { |
| | | for (int c = 0; c < vv.ChildrenCount; c++) |
| | | { |
| | | var viewfl = vv.GetChildren(c); |
| | | if (viewfl.GetType() == typeof(FrameLayout)) |
| | | { |
| | | var fl = viewfl as FrameLayout; |
| | | if ((fl.Tag as Function).sid!= alinkStatusData.sid) { |
| | | //不是当前音乐不会更新状态 |
| | | continue; |
| | | } |
| | | if (fl != null && fl.Name == "parentfl") |
| | | { |
| | | for (int i = 0; i < fl.ChildrenCount; i++) |
| | | { |
| | | var viewfl1 = fl.GetChildren(i); |
| | | if (viewfl1.GetType() == typeof(FrameLayout)) |
| | | { |
| | | var fl1 = viewfl1 as FrameLayout; |
| | | if (fl1 != null && fl1.Name == "musicparentfl") |
| | | { |
| | | for (int j = 0; j < fl1.ChildrenCount; j++) |
| | | { |
| | | |
| | | if (fl1.GetChildren(j).GetType() == typeof(Button)) |
| | | { |
| | | var btn = fl1.GetChildren(j) as Button; |
| | | if (btn == null ||btn.Name==null) |
| | | { |
| | | continue; |
| | | } |
| | | switch (btn.Name) |
| | | { |
| | | case "song": |
| | | { |
| | | var s = alinkStatusData.status.Find((o) => o.key == KeyProperty.song_name); |
| | | if (s != null) |
| | | { |
| | | btn.Text = s.value; |
| | | } |
| | | } |
| | | break; |
| | | case "playstatus": |
| | | { |
| | | |
| | | var s = alinkStatusData.status.Find((o) => o.key == KeyProperty.on_off); |
| | | if (s != null) |
| | | { |
| | | if (s.value == ValueProperty.on) |
| | | { |
| | | btn.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | btn.IsSelected = false; |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch { } |
| | | }); |