| | |
| | | { |
| | | while (frame.Parent != null) |
| | | { |
| | | A31MusicModel.LogMusic("已启动更新音乐列表某一条音乐状态的线程"); |
| | | //A31MusicModel.LogMusic("已启动更新音乐列表某一条音乐状态的线程"); |
| | | System.Threading.Thread.Sleep(1000); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | |
| | | if (a31MusicModel.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString()) |
| | | { |
| | | volIconBtn.Visible = true; |
| | | songNameBtn.TextColor = UI.Music.Color.SelectedColor; |
| | | songNameBtn.TextColor = UI.Music.MusicColor.SelectedColor; |
| | | songNameBtn.X = Application.GetRealWidth(48); |
| | | artistNameBtn.X = songNameBtn.Right; |
| | | artistNameBtn.TextColor = UI.Music.Color.SelectedColor; |
| | | artistNameBtn.TextColor = UI.Music.MusicColor.SelectedColor; |
| | | } |
| | | else |
| | | { |
| | | volIconBtn.Visible = false; |
| | | songNameBtn.TextColor = UI.Music.Color.MusicTxet14Color; |
| | | songNameBtn.TextColor = UI.Music.MusicColor.MusicTxet14Color; |
| | | songNameBtn.X = Application.GetRealWidth(16); |
| | | artistNameBtn.X = songNameBtn.Right; |
| | | artistNameBtn.TextColor = UI.Music.Color.MusicNoTxetColor; |
| | | artistNameBtn.TextColor = UI.Music.MusicColor.MusicNoTxetColor; |
| | | } |
| | | |
| | | |
| | |
| | | }); |
| | | updateSelectedMusicThread.Start(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放音乐 |
| | | /// </summary> |
| | | /// <param name="middViewLayout">上下拉动父控件</param> |
| | | /// <param name="musicSource">音乐源</param> |
| | | /// <param name="listName">播放列表名</param> |
| | | /// <param name="musicList">播放音乐列表</param> |
| | | /// <param name="a31MusicModel">音乐播放器</param> |
| | | public static void playMusuc(VerticalRefreshLayout middViewLayout, string musicSource, string listName,List<MusicInfo> musicList, A31MusicModel a31MusicModel, FrameLayout frame=null) |
| | | { |
| | | for (int i = 0; i < musicList.Count; i++) |
| | | { |
| | | var songs = musicList[i]; |
| | | if (songs == null) |
| | | { |
| | | continue; |
| | | } |
| | | UI.Music.View.SongView songView = new UI.Music.View.SongView(); |
| | | songView.SongFrameLayout(middViewLayout, songs); |
| | | switch (musicSource) |
| | | { |
| | | case "本地音乐": |
| | | { |
| | | songs.URL = "http://" + new Shared.Net.NetWiFi().IpAddress + ":" + com.hdl.on.Server.Port + "/" + songs.ID; |
| | | } |
| | | break; |
| | | case "USB": |
| | | { |
| | | songView.clickBtn.Tag = i + 1; |
| | | } |
| | | break; |
| | | case "我的列表": |
| | | { |
| | | ///删除控件 |
| | | var delBtn = new Button |
| | | { |
| | | BackgroundColor = MusicColor.MusicDelColor, |
| | | Text = Language.StringByID(StringId.delMusic), |
| | | TextColor = MusicColor.WhiteColor, |
| | | TextSize = TextSize.Text16, |
| | | }; |
| | | songView.musicViewFl.AddRightView(delBtn); |
| | | delBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | musicList.Remove(songs); |
| | | A31MusicModel.Save(); |
| | | songView.musicViewFl.RemoveFromParent(); |
| | | }; |
| | | } |
| | | break; |
| | | case "播放列表": |
| | | { |
| | | songView.loveIcon.Visible = false; |
| | | songView.addIcon.Visible = false; |
| | | var wText = songView.songBtn.GetTextWidth() + Application.GetRealWidth(15); |
| | | if (wText > Application.GetRealWidth(280)) |
| | | { |
| | | wText = Application.GetRealWidth(280);//(歌曲+歌手)宽度最大值时220 |
| | | } |
| | | songView.songBtn.Width = wText; |
| | | songView.singerBtn.X = songView.songBtn.Right; |
| | | songView.singerBtn.Width = Application.GetRealWidth(280) - wText;//歌名长度小于220才可以显示歌手出来 |
| | | songView.singerBtn.Text = string.IsNullOrEmpty(songs.Artist) ? "-Unkonw" : "-" + songs.Artist.Trim(); |
| | | songView.clickBtn.Width = Application.GetRealWidth(344); |
| | | songView.clickBtn.Tag = i + 1;//标记播放哪一首歌曲 |
| | | } |
| | | break; |
| | | } |
| | | |
| | | //添加喜爱音乐控件 |
| | | songView.loveIcon.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | songView.loveIcon.IsSelected = !songView.loveIcon.IsSelected; |
| | | if (songView.loveIcon.IsSelected) |
| | | { |
| | | ///查找音乐是否存在在列表 |
| | | var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL); |
| | | if (music1 == null) |
| | | { |
| | | ///没有存在就添加 |
| | | A31MusicModel.Current.LoveMusicInfoList.Add(songs); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ///查找音乐是否存在在列表 |
| | | var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL); |
| | | if (music1 != null) |
| | | { |
| | | ///存在就删除 |
| | | A31MusicModel.Current.LoveMusicInfoList.Remove(songs); |
| | | } |
| | | |
| | | if (musicSource == "我的最爱") |
| | | { |
| | | songView.musicViewFl.RemoveFromParent(); |
| | | } |
| | | |
| | | } |
| | | A31MusicModel.Save(); |
| | | }; |
| | | //添加到我的列表 |
| | | songView.addIcon.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | new HDL_ON.UI.Music.View.DialogView { }.FieListView(songs); |
| | | }; |
| | | ///点击播放事件 |
| | | songView.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | System.Threading.Thread.Sleep(50); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //移除界面 |
| | | A31MusicModel.Current.A31PlayStatus.Title = songView.songBtn.Text; |
| | | if (frame != null) |
| | | { |
| | | frame.RemoveFromParent(); |
| | | } |
| | | MainPage.BasePageView.RemoveViewByTag("Music"); |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | if (musicSource == "本地音乐"|| musicSource == "我的最爱"|| musicSource == "我的列表") |
| | | { |
| | | SendMethod.PushList(songs, listName, musicList, a31MusicModel,musicSource); |
| | | } |
| | | else if (musicSource == "USB"|| musicSource == "播放列表") |
| | | { |
| | | SendMethod.ListMusicPlay(listName, songView.clickBtn.Tag, A31MusicModel.Current); |
| | | } |
| | | }); |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |