From a499dceb02f181e64956431ed0c682dd7d2ce7d7 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期二, 04 八月 2020 17:45:20 +0800 Subject: [PATCH] 2020-08-04-1 --- HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs | 216 ++++++++++++++++++++++------------------------------- 1 files changed, 89 insertions(+), 127 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs index f06a00d..9a98f45 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs @@ -11,9 +11,7 @@ /// <summary> /// 褰撳墠瀵硅薄鏋勯�犲嚱鏁� /// </summary> - public A31PlayMusicPage() - { - } + public A31PlayMusicPage() { } /// <summary> /// 閲嶅啓RemoveFromParent鏂规硶 /// </summary> @@ -38,13 +36,14 @@ /// new甯冨眬鐣岄潰 /// </summary> View.PlayView playView = new View.PlayView(); - + public void Show() { + ///1绉掑畾鏃舵洿鏂扮姸鎬� timerUpdateStatus(); #region ---鐣岄潰甯冨眬--- - this.BackgroundColor = Color.ViewColor; + this.BackgroundColor = MusicColor.ViewColor; var topView = new TopView(); topView.setBtn.Visible = true; this.AddChidren(topView.TopFLayoutView()); @@ -60,8 +59,6 @@ a31MusicSourcePage.Show(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; - - var middLayout = new FrameLayout { Y = topView.fLayout.Bottom, @@ -70,6 +67,8 @@ this.AddChidren(middLayout); ///鍔犺浇鎾斁闊充箰鐣岄潰鐨勬帶浠舵柟娉� playView.viewFrameLayout(middLayout); + #endregion + #region ---鎺т欢鐨勭偣鍑讳簨浠�--- //鏀惰棌鍥炬爣浜嬩欢 playView.collectIconBtn.MouseUpEventHandler += (sender, e) => { @@ -84,7 +83,6 @@ } }; - #endregion //蹇繘婊戝姩寮硅捣浜嬩欢; playView.diyArcSeekBar.OnStopTrackingTouchEvent+= (sender, e) => { @@ -202,80 +200,19 @@ myListView.popFra.MouseUpEventHandler += removeFromParentView; #endregion loading.Start(); - System.Threading.Tasks.Task.Run(() => + GetMusicList((listName) => { - string playListName = "List"; - string sourceName = "SourceName"; - try - { - if (A31MusicModel.Current.A31PlayStatus.Source == "STATION-NETWORK") - { - A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>(); - return; - } - if (A31MusicModel.Current.A31PlayStatus.Source == "AIRPLAY") - { - A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>(); - return; - } - var playString = SendMethod.GetCurrentPlayList(A31MusicModel.Current); - A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>(); - var se = System.Security.SecurityElement.FromString(playString); - while (se.Children != null) - { - se = se.Children[0] as System.Security.SecurityElement; - } - playListName = SecurityElement.FromString(se.Text).SearchForChildByTag("ListName").Text; - sourceName = SecurityElement.FromString(se.Text).SearchForChildByTag("ListInfo").SearchForTextOfTag("SourceName"); - foreach (SecurityElement track in SecurityElement.FromString(se.Text).SearchForChildByTag("Tracks").Children) - { - MusicInfo musicInfo = new MusicInfo(); - musicInfo.URL = track.SearchForTextOfTag("URL").Replace("&", "&amp;"); - var metadata = track.SearchForTextOfTag("Metadata"); - musicInfo.SourceName = track.SearchForTextOfTag("Source"); - if (string.IsNullOrEmpty(metadata)) - { - continue; - } - if (A31MusicModel.IsJson(metadata)) - { - var qqSong = Newtonsoft.Json.JsonConvert.DeserializeObject<SendMethod.A31QQSong>(metadata); - musicInfo.Album = qqSong.album; - musicInfo.Title = qqSong.title; - musicInfo.Artist = qqSong.creator; - } - else - { - metadata = metadata.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "").Replace("&", "&amp;"); - var item = SecurityElement.FromString(metadata).SearchForChildByTag("item"); - musicInfo.Title = item.SearchForTextOfTag("dc:title"); - musicInfo.Artist = item.SearchForTextOfTag("upnp:artist"); - musicInfo.Album = item.SearchForTextOfTag("upnp:album"); - musicInfo.Duration = item.SearchForTextOfTag("res"); - musicInfo.AlbumId = item.SearchForTextOfTag("song:albumid"); - } - A31MusicModel.Current.CurrentPlayMusicInfoList.Add(musicInfo); - } - } - catch { } - finally - { - Application.RunOnMainThread(() => - { - loading.Hide(); - PlayListView(myListView.popFra, myListView.verticalScrolViewLayout, playListName); - UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout); - }); - } + loading.Hide(); + PlayListView(myListView.popFra, myListView.verticalScrolViewLayout, listName); + UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout); }); - + }; ///闊抽噺鍥炬爣鐐瑰嚮浜嬩欢 playView.volIconBtn.MouseUpEventHandler += (sender, e) => { if (A31MusicModel.Current.ServerClientType == 1 && A31MusicModel.Current.Slave.slave_list.Count != 0) { ///涓绘挱鏀惧櫒 - //new View.DialogView { }.PlayerVolumeView(A31MusicModel.Current); var volumeView = new View.DialogView { }; volumeView.PlayerVolumeView(A31MusicModel.Current); volumeView.UpdateVolume(); @@ -350,7 +287,7 @@ } }; - + #endregion } /// <summary> /// 瀹氫箟鍏ㄥ眬绾跨▼ @@ -563,24 +500,6 @@ playView.playOrderBtn.Enable = false; break; case "BLUETOOTH"://钃濈墮 - playView.loveBtn.Alpha = 0.5f; - playView.loveBtn.Enable = false; - - playView.playlistBtn.Alpha = 0.5f; - playView.playlistBtn.Enable = false; - - playView.prevBtn.Alpha = 0.5f; - playView.prevBtn.Enable = false; - - playView.nextBtn.Alpha = 0.5f; - playView.nextBtn.Enable = false; - - playView.playOrderBtn.Alpha = 0.5f; - playView.playOrderBtn.Enable = false; - - break; - - case "LINE-IN"://绾胯矾杈撳叆 playView.loveBtn.Alpha = 0.5f; playView.loveBtn.Enable = false; @@ -596,8 +515,8 @@ playView.playOrderBtn.Alpha = 0.5f; playView.playOrderBtn.Enable = false; - break; + break; default: playView.diyArcSeekBar.IsClickable = false; playView.loveBtn.Alpha = 0.5f; @@ -618,44 +537,13 @@ } } /// <summary> - /// 鏄剧ず褰撳墠鎾斁闊充箰View + /// 鍔犺浇鎾斁闊充箰鍒楄〃View /// </summary> /// <param name="verticalScrolViewLayout"></param> void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout, string playListName) { verticalScrolViewLayout.RemoveAll(); - int number = 0; - for (int i = 0; i < A31MusicModel.Current.CurrentPlayMusicInfoList.Count; i++) - { - number++; - var songs = A31MusicModel.Current.CurrentPlayMusicInfoList[i]; - View.SongView songView = new View.SongView(); - songView.SongFrameLayout(verticalScrolViewLayout, songs); - songView.loveIcon.Visible = false; - songView.addIcon.Visible = false; - songView.clickBtn.Width = Application.GetRealWidth(344); - songView.clickBtn.Tag = number;//鏍囪鎾斁鍝竴棣栨瓕鏇� - ///鐐瑰嚮鎾斁浜嬩欢 - songView.clickBtn.MouseUpEventHandler += (sender, e) => - { - System.Threading.Tasks.Task.Run(() => - { - System.Threading.Thread.Sleep(50); - Application.RunOnMainThread(() => - { - //绉婚櫎鐣岄潰 - frameLayout.RemoveFromParent(); - A31MusicModel.Current.A31PlayStatus.Title = songView.songBtn.Text; - System.Threading.Tasks.Task.Run(() => - { - SendMethod.ListMusicPlay(playListName, songView.clickBtn.Tag, A31MusicModel.Current); - }); - }); - }); - - }; - - } + UI2.FuntionControlView.Music.UpdateThread.playMusuc(verticalScrolViewLayout,"鎾斁鍒楄〃", playListName, A31MusicModel.Current.CurrentPlayMusicInfoList,A31MusicModel.Current,frameLayout); } /// <summary> /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 @@ -664,5 +552,79 @@ { UI2.FuntionControlView.Music.UpdateThread.updateThread(frameLayout, middViewLayout, A31MusicModel.Current); } + /// <summary> + /// 璇诲彇鎾斁闊充箰鍒楄〃 + /// </summary> + /// <param name="action"></param> + void GetMusicList(Action<string> action) { + System.Threading.Tasks.Task.Run(() => + { + string playListName = "List"; + string sourceName = "SourceName"; + try + { + if (A31MusicModel.Current.A31PlayStatus.Source == "STATION-NETWORK") + { + A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>(); + return; + } + if (A31MusicModel.Current.A31PlayStatus.Source == "AIRPLAY") + { + A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>(); + return; + } + var playString = SendMethod.GetCurrentPlayList(A31MusicModel.Current); + A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>(); + var se = System.Security.SecurityElement.FromString(playString); + while (se.Children != null) + { + se = se.Children[0] as System.Security.SecurityElement; + } + playListName = SecurityElement.FromString(se.Text).SearchForChildByTag("ListName").Text; + sourceName = SecurityElement.FromString(se.Text).SearchForChildByTag("ListInfo").SearchForTextOfTag("SourceName"); + foreach (SecurityElement track in SecurityElement.FromString(se.Text).SearchForChildByTag("Tracks").Children) + { + MusicInfo musicInfo = new MusicInfo(); + musicInfo.URL = track.SearchForTextOfTag("URL").Replace("&", "&amp;"); + var metadata = track.SearchForTextOfTag("Metadata"); + musicInfo.SourceName = track.SearchForTextOfTag("Source"); + if (string.IsNullOrEmpty(metadata)) + { + continue; + } + if (A31MusicModel.IsJson(metadata)) + { + var qqSong = Newtonsoft.Json.JsonConvert.DeserializeObject<SendMethod.A31QQSong>(metadata); + musicInfo.Album = qqSong.album; + musicInfo.Title = qqSong.title; + musicInfo.Artist = qqSong.creator; + } + else + { + metadata = metadata.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "").Replace("&", "&amp;"); + var item = SecurityElement.FromString(metadata).SearchForChildByTag("item"); + musicInfo.Title = item.SearchForTextOfTag("dc:title"); + musicInfo.Artist = item.SearchForTextOfTag("upnp:artist"); + musicInfo.Album = item.SearchForTextOfTag("upnp:album"); + musicInfo.Duration = item.SearchForTextOfTag("res"); + musicInfo.AlbumId = item.SearchForTextOfTag("song:albumid"); + } + A31MusicModel.Current.CurrentPlayMusicInfoList.Add(musicInfo); + } + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + action(playListName); + //loading.Hide(); + //PlayListView(myListView.popFra, myListView.verticalScrolViewLayout, playListName); + //UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout); + }); + } + }); + + } } } -- Gitblit v1.8.0