| | |
| | | { |
| | | public class A31PlayMusicPage : FrameLayout |
| | | { |
| | | public A31PlayMusicPage() |
| | | { |
| | | } |
| | | /// <summary> |
| | | /// 当前对象构造函数 |
| | | /// </summary> |
| | | public A31PlayMusicPage() { } |
| | | /// <summary> |
| | | /// 重写RemoveFromParent方法 |
| | | /// </summary> |
| | | public override void RemoveFromParent() |
| | | { |
| | | base.RemoveFromParent(); |
| | |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 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()); |
| | |
| | | { |
| | | RemoveFromParent(); |
| | | }; |
| | | topView.setBtn.MouseUpEventHandler += (sender, e) => |
| | | topView.clickSetBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | A31MusicSourcePage a31MusicSourcePage = new A31MusicSourcePage(); |
| | | MainPage.BasePageView.AddChidren(a31MusicSourcePage); |
| | | a31MusicSourcePage.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | |
| | | |
| | | var middLayout = new FrameLayout |
| | | { |
| | | Y = topView.fLayout.Bottom, |
| | |
| | | this.AddChidren(middLayout); |
| | | ///加载播放音乐界面的控件方法 |
| | | playView.viewFrameLayout(middLayout); |
| | | #endregion |
| | | #region ---控件的点击事件--- |
| | | //收藏图标事件 |
| | | playView.collectIconBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | } |
| | | |
| | | }; |
| | | #endregion |
| | | //快进滑动事件; |
| | | EventHandler<int> seekClick = (sender, e) => |
| | | //快进滑动弹起事件; |
| | | playView.diyArcSeekBar.OnStopTrackingTouchEvent+= (sender, e) => |
| | | { |
| | | int totalSecond = (int)(playView.diyArcSeekBar.Progress * 1.0f / 100 * int.Parse(A31MusicModel.Current.A31PlayStatus.totlen) / 1000); |
| | | //分钟 |
| | |
| | | SendMethod.Seek(time, A31MusicModel.Current); |
| | | A31MusicModel.Current.A31PlayStatus.curpos = (DateTime.Parse(time) - DateTime.Parse("00:00:00")).TotalMilliseconds.ToString(); |
| | | }; |
| | | //playView.diyArcSeekBar.OnProgressChangedEvent += seekClick; |
| | | playView.diyArcSeekBar.OnStopTrackingTouchEvent += seekClick;//快进滑动不发命令, |
| | | |
| | | ///切换播放模式点击事件; |
| | | playView.playOrderBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | { |
| | | #region 布局界面--- |
| | | Loading loading = new Loading(); |
| | | FrameLayout popFra = new FrameLayout() |
| | | UI2.FuntionControlView.Music.View.MyListView myListView = new UI2.FuntionControlView.Music.View.MyListView(); |
| | | myListView.frameLayout(this, A31MusicModel.Current); |
| | | myListView.dialogFra.AddChidren(loading);//dialogFra刷新图标父控件 |
| | | ///下拉刷新 |
| | | myListView.verticalScrolViewLayout.BeginHeaderRefreshingAction += () => |
| | | { |
| | | BackgroundColor = Color.PopupBackgroundColor, |
| | | //结束刷新 |
| | | myListView.verticalScrolViewLayout.EndHeaderRefreshing(); |
| | | }; |
| | | this.AddChidren(popFra); |
| | | |
| | | FrameLayout dialogFra = new FrameLayout() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(187), |
| | | Width = Application.GetRealWidth(344), |
| | | Height = Application.GetRealHeight(460), |
| | | BackgroundColor = Color.WhiteColor, |
| | | Radius = (uint)Application.GetRealHeight(12), |
| | | }; |
| | | popFra.AddChidren(dialogFra); |
| | | dialogFra.AddChidren(loading);//dialogFra刷新图标父控件 |
| | | |
| | | FrameLayout topFra = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(344), |
| | | Height = Application.GetRealHeight(50), |
| | | }; |
| | | dialogFra.AddChidren(topFra); |
| | | Button orderIconBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(11), |
| | | Width = Application.GetMinRealAverage(28), |
| | | Height = Application.GetMinRealAverage(28), |
| | | }; |
| | | topFra.AddChidren(orderIconBtn); |
| | | Button orderTxetBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(60), |
| | | Y = Application.GetRealHeight(14), |
| | | Width = Application.GetRealWidth(120), |
| | | Height = Application.GetRealHeight(22), |
| | | TextColor = Color.TextColor, |
| | | TextSize = TextSize.Text16, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | topFra.AddChidren(orderTxetBtn); |
| | | switch (A31MusicModel.Current.A31PlayStatus.loop) |
| | | { |
| | | //0列表循环,1单曲循环,2随机播放; |
| | | case "0": |
| | | orderIconBtn.UnSelectedImagePath = "MusicIcon/list.png"; |
| | | orderTxetBtn.Text = Language.StringByID(StringId.listMode); |
| | | break; |
| | | |
| | | case "1": |
| | | orderIconBtn.UnSelectedImagePath = "MusicIcon/single.png"; |
| | | orderTxetBtn.Text = Language.StringByID(StringId.singleMode); |
| | | |
| | | break; |
| | | case "2": |
| | | orderIconBtn.UnSelectedImagePath = "MusicIcon/random.png"; |
| | | orderTxetBtn.Text = Language.StringByID(StringId.randomMode); |
| | | break; |
| | | } |
| | | Button backIextBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(288),//300 |
| | | Y = Application.GetRealHeight(15), |
| | | Width = Application.GetRealWidth(28 + 12),//28 |
| | | Height = Application.GetRealHeight(20), |
| | | TextID = StringId.cancelMusic, |
| | | TextColor = Color.MusicNoTxetColor, |
| | | TextSize = TextSize.Text14, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | topFra.AddChidren(backIextBtn); |
| | | Button lineBtn = new Button |
| | | { |
| | | Y = topFra.Height - 1, |
| | | Width = Application.GetRealWidth(344), |
| | | Height = H_W.Line, |
| | | BackgroundColor = Color.LineColor, |
| | | }; |
| | | topFra.AddChidren(lineBtn); |
| | | VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout |
| | | { |
| | | Y = Application.GetRealHeight(50), |
| | | Height = Application.GetRealHeight(410), |
| | | Width = Application.GetRealWidth(344), |
| | | }; |
| | | dialogFra.AddChidren(verticalScrolViewLayout); |
| | | ///移除界面 |
| | | EventHandler<MouseEventArgs> removeFromParentView = (sen, e1) => |
| | | { |
| | | |
| | | if (updateSelectedMusicThread != null) |
| | | { |
| | | try |
| | | { |
| | | if (updateSelectedMusicThread.IsAlive) |
| | | { |
| | | updateSelectedMusicThread.Abort(); |
| | | ///关闭线程 |
| | | } |
| | | } |
| | | catch { } |
| | | } |
| | | |
| | | popFra.RemoveFromParent(); |
| | | myListView.popFra.RemoveFromParent(); |
| | | }; |
| | | backIextBtn.MouseUpEventHandler += removeFromParentView; |
| | | popFra.MouseUpEventHandler += removeFromParentView; |
| | | myListView.backIextBtn.MouseUpEventHandler += removeFromParentView; |
| | | 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(popFra, verticalScrolViewLayout, playListName); |
| | | UpdateSelectedMusic(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(); |
| | |
| | | } |
| | | |
| | | }; |
| | | |
| | | #endregion |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 定义全局线程 |
| | | /// </summary> |
| | | System.Threading.Thread timerThread; |
| | | /// <summary> |
| | | /// 定时更新状态 |
| | |
| | | { |
| | | playView.playBtn.IsSelected = false; |
| | | //停止播放 |
| | | playView.startTimeBtn.Text = "00:00"; |
| | | playView.startTimeBtn.Text =playTime; |
| | | } |
| | | playView.songNameTextView.Text = (A31MusicModel.Current.A31PlayStatus.Title == null ? "Unkown" : A31MusicModel.Current.A31PlayStatus.Title); |
| | | playView.singerBtn.Text = (A31MusicModel.Current.A31PlayStatus.Artist == null ? "Unkown" : A31MusicModel.Current.A31PlayStatus.Artist.Trim()); |
| | |
| | | playView.playOrderBtn.Alpha = 1; |
| | | playView.playOrderBtn.Enable = true; |
| | | |
| | | //btnPlay.Alpha = 1; |
| | | //btnPlay.Enable = true; |
| | | |
| | | playView.volSeekBar.IsClickable = true; |
| | | playView.diyArcSeekBar.IsClickable = true; |
| | | |
| | | switch (A31MusicModel.Current.A31PlayStatus.Source) |
| | | { |
| | | |
| | | case "QPLAY"://QQ音乐 |
| | | //currentsource.UnSelectedImagePath = "MusicIcon/qqmusic1.png"; |
| | | playView.loveBtn.Alpha = 0.5f; |
| | | playView.loveBtn.Enable = false; |
| | | break; |
| | | case "AIRPLAY"://酷狗音乐 |
| | | //currentsource.UnSelectedImagePath = "MusicIcon/kumusic.png"; |
| | | playView.loveBtn.Alpha = 0.5f; |
| | | playView.loveBtn.Enable = false; |
| | | playView.volSeekBar.IsClickable = false; |
| | | playView.diyArcSeekBar.IsClickable = false; |
| | | break; |
| | | case "SONGLIST-NETWORK"://本地音乐 |
| | | //currentsource.UnSelectedImagePath = "MusicIcon/musicMusic1.png"; |
| | | break; |
| | | case "SONGLIST-LOCAL"://USB |
| | | //currentsource.UnSelectedImagePath = "MusicIcon/USB1.png"; |
| | | break; |
| | | case "RADIO-NETWORK"://在线电台 |
| | | //currentsource.UnSelectedImagePath = "MusicIcon/local1.png"; |
| | | playView.playlistBtn.Alpha = 1; |
| | | playView.playlistBtn.Enable = true; |
| | | |
| | |
| | | playView.playOrderBtn.Alpha = 0.5f; |
| | | playView.playOrderBtn.Enable = false; |
| | | break; |
| | | |
| | | case "STATION-NETWORK"://Pandora电台 |
| | | playView.volSeekBar.IsClickable = false; |
| | | //currentsource.UnSelectedImagePath = "MusicIcon/pandora1.png"; |
| | | playView.loveBtn.Alpha = 0.5f; |
| | | playView.loveBtn.Enable = false; |
| | | |
| | | playView.prevBtn.Alpha = 0.5f; |
| | | playView.prevBtn.Enable = false; |
| | | |
| | | playView.playOrderBtn.Alpha = 0.5f; |
| | | playView.playOrderBtn.Enable = false; |
| | | break; |
| | | |
| | | case "BLUETOOTH"://蓝牙 |
| | | // currentsource.UnSelectedImagePath = "MusicIcon/bluetooth1.png"; |
| | | 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; |
| | | |
| | | //btnPlay.Alpha = 0.5f; |
| | | //btnPlay.Enable = false; |
| | | break; |
| | | |
| | | |
| | | case "LINE-IN"://线路输入 |
| | | // currentsource.UnSelectedImagePath = "MusicIcon/muiscline1.png"; |
| | | playView.loveBtn.Alpha = 0.5f; |
| | | playView.loveBtn.Enable = false; |
| | | |
| | |
| | | playView.playOrderBtn.Alpha = 0.5f; |
| | | playView.playOrderBtn.Enable = false; |
| | | |
| | | //btnPlay.Alpha = 0.5f; |
| | | //btnPlay.Enable = false; |
| | | break; |
| | | |
| | | default: |
| | | //currentsource.UnSelectedImagePath = "MusicIcon/dlna.png"; |
| | | playView.volSeekBar.IsClickable = false; |
| | | playView.diyArcSeekBar.IsClickable = false; |
| | | playView.loveBtn.Alpha = 0.5f; |
| | | playView.loveBtn.Enable = false; |
| | | |
| | |
| | | playView.playOrderBtn.Enable = false; |
| | | break; |
| | | } |
| | | //if (A31MusicModel.Current.A31PlayStatus.playSource == "UPnPServer") |
| | | //{ |
| | | // currentsource.UnSelectedImagePath = "MusicIcon/dlna.png"; |
| | | //} |
| | | //else if (A31MusicModel.Current.A31PlayStatus.playSource == "Tidal") |
| | | //{ |
| | | // currentsource.UnSelectedImagePath = "MusicIcon/Tidal1.png"; |
| | | //} |
| | | } |
| | | /// <summary> |
| | | /// 显示当前播放音乐View |
| | | /// 加载播放音乐列表View |
| | | /// </summary> |
| | | /// <param name="verticalScrolViewLayout"></param> |
| | | void PlayListView(FrameLayout frameLayout, VerticalScrolViewLayout verticalScrolViewLayout, string playListName) |
| | | 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]; |
| | | if (string.IsNullOrEmpty(songs.Title)) |
| | | { |
| | | //防止歌曲名字为空抛异常 |
| | | songs.Title = " "; |
| | | } |
| | | if (string.IsNullOrEmpty(songs.Artist)) |
| | | { |
| | | //防止歌手名字为空抛异常 |
| | | songs.Artist = " "; |
| | | } |
| | | FrameLayout musicViewFl = new FrameLayout |
| | | { |
| | | Width = Application.GetRealWidth(375), |
| | | Height = Application.GetRealHeight(44), |
| | | }; |
| | | verticalScrolViewLayout.AddChidren(musicViewFl); |
| | | //列表当前播放音乐图标 |
| | | Button playIconBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(10), |
| | | Width = Application.GetMinRealAverage(24), |
| | | Height = Application.GetMinRealAverage(24), |
| | | UnSelectedImagePath = "MusicIcon/playStatus.png", |
| | | Visible = false, |
| | | Name = "playStatus", |
| | | Tag = songs.URL, |
| | | }; |
| | | musicViewFl.AddChidren(playIconBtn); |
| | | //歌曲控件 |
| | | Button songBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(11), |
| | | Width = Application.GetRealWidth(100), |
| | | Height = Application.GetRealHeight(22), |
| | | TextColor = Color.MusicTxet14Color, |
| | | TextSize = TextSize.Text16, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Name = "song", |
| | | Tag = songs.URL, |
| | | Text = songs.Title.Trim() |
| | | }; |
| | | musicViewFl.AddChidren(songBtn); |
| | | var wText = songBtn.GetTextWidth();//获取文本宽度 |
| | | ///(歌曲+歌手)宽度最大值时280 |
| | | if (wText > 280) |
| | | { |
| | | |
| | | songBtn.Width = Application.GetRealWidth(280); |
| | | } |
| | | else |
| | | { |
| | | songBtn.Width = wText + 5; |
| | | } |
| | | //歌手控件 |
| | | Button singerBtn = new Button |
| | | { |
| | | X = songBtn.Right, |
| | | Y = Application.GetRealHeight(11), |
| | | Width = Application.GetRealWidth(280 - songBtn.Width), |
| | | Height = Application.GetRealHeight(22), |
| | | TextColor = Color.MusicNoTxetColor, |
| | | TextSize = TextSize.Text12, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | //Text =("-" +songs.Artist).Trim(), |
| | | Name = "singer", |
| | | Tag = songs.URL, |
| | | Text = "-" + songs.Artist.Trim() |
| | | }; |
| | | musicViewFl.AddChidren(singerBtn); |
| | | if (wText > 280) |
| | | { |
| | | ///歌名长度小于250才可以显示歌手出来 |
| | | singerBtn.Width = Application.GetRealWidth(0); |
| | | } |
| | | |
| | | //点击控件 |
| | | Button clickBtn = new Button |
| | | { |
| | | Width = Application.GetRealWidth(280), |
| | | Height = Application.GetRealHeight(44), |
| | | Tag = number,//标记播放哪一首歌曲 |
| | | }; |
| | | musicViewFl.AddChidren(clickBtn); |
| | | ///点击播放事件 |
| | | clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (updateSelectedMusicThread != null) |
| | | { |
| | | try |
| | | { |
| | | if (updateSelectedMusicThread.IsAlive) |
| | | { |
| | | updateSelectedMusicThread.Abort(); |
| | | ///关闭线程 |
| | | } |
| | | } |
| | | catch { } |
| | | } |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | System.Threading.Thread.Sleep(50); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //移除界面 |
| | | frameLayout.RemoveFromParent(); |
| | | A31MusicModel.Current.A31PlayStatus.Title = songBtn.Text; |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | SendMethod.ListMusicPlay(playListName, clickBtn.Tag, A31MusicModel.Current); |
| | | }); |
| | | }); |
| | | }); |
| | | |
| | | }; |
| | | |
| | | } |
| | | UI2.FuntionControlView.Music.UpdateThread.playMusuc(verticalScrolViewLayout,"播放列表", playListName, A31MusicModel.Current.CurrentPlayMusicInfoList,A31MusicModel.Current,frameLayout); |
| | | } |
| | | /// <summary> |
| | | /// 定时更新当前播放音乐 |
| | | /// </summary> |
| | | System.Threading.Thread updateSelectedMusicThread; |
| | | void UpdateSelectedMusic(VerticalScrolViewLayout middViewLayout) |
| | | void UpdateSelectedMusic(FrameLayout frameLayout, VerticalRefreshLayout middViewLayout) |
| | | { |
| | | updateSelectedMusicThread = new System.Threading.Thread(() => |
| | | 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(() => |
| | | { |
| | | while (this.Parent != null) |
| | | string playListName = "List"; |
| | | string sourceName = "SourceName"; |
| | | try |
| | | { |
| | | System.Threading.Thread.Sleep(1000); |
| | | 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(() => |
| | | { |
| | | try |
| | | { |
| | | for (int i = 0; i < middViewLayout.ChildrenCount; i++) |
| | | { |
| | | FrameLayout view = (FrameLayout)middViewLayout.GetChildren(i); |
| | | var volIconBtn = (Button)view.GetChildren(0);//直接FrameLayout父控件找到该控件Button |
| | | var songNameBtn = (Button)view.GetChildren(1);//直接FrameLayout父控件找到该控件Button |
| | | var artistNameBtn = (Button)view.GetChildren(2);//直接FrameLayout父控件找到该控件Button |
| | | if (A31MusicModel.Current.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString()) |
| | | { |
| | | volIconBtn.Visible = true; |
| | | songNameBtn.TextColor = Color.SelectedColor; |
| | | songNameBtn.X = Application.GetRealWidth(48); |
| | | artistNameBtn.X = songNameBtn.Right; |
| | | artistNameBtn.TextColor = Color.SelectedColor; |
| | | } |
| | | else |
| | | { |
| | | volIconBtn.Visible = false; |
| | | songNameBtn.TextColor = Color.MusicTxet14Color; |
| | | songNameBtn.X = Application.GetRealWidth(16); |
| | | artistNameBtn.X = songNameBtn.Right; |
| | | artistNameBtn.TextColor = Color.MusicNoTxetColor; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | catch { } |
| | | |
| | | action(playListName); |
| | | //loading.Hide(); |
| | | //PlayListView(myListView.popFra, myListView.verticalScrolViewLayout, playListName); |
| | | //UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout); |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }; |
| | | updateSelectedMusicThread.Start(); |
| | | }); |
| | | |
| | | } |
| | | } |
| | | } |