| | |
| | | /// <summary> |
| | | /// 当前对象构造函数 |
| | | /// </summary> |
| | | public A31PlayMusicPage() |
| | | { |
| | | } |
| | | public A31PlayMusicPage() { } |
| | | /// <summary> |
| | | /// 重写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()); |
| | |
| | | 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 |
| | | //快进滑动弹起事件; |
| | | playView.diyArcSeekBar.OnStopTrackingTouchEvent+= (sender, e) => |
| | | { |
| | |
| | | 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(); |
| | |
| | | } |
| | | |
| | | }; |
| | | |
| | | #endregion |
| | | } |
| | | /// <summary> |
| | | /// 定义全局线程 |
| | |
| | | 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; |
| | |
| | | |
| | | playView.playOrderBtn.Alpha = 0.5f; |
| | | playView.playOrderBtn.Enable = false; |
| | | break; |
| | | |
| | | break; |
| | | default: |
| | | playView.diyArcSeekBar.IsClickable = false; |
| | | playView.loveBtn.Alpha = 0.5f; |
| | |
| | | } |
| | | } |
| | | /// <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> |
| | | /// 定时更新当前播放音乐 |
| | |
| | | { |
| | | 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); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |
| | | } |