wjc
2022-01-10 52c945d6f5628e7fac328a5df8bc295ccfc5966b
HDL_ON/UI/UI2/FuntionControlView/Music/A31SongPlay.cs
@@ -19,7 +19,7 @@
            this.BackgroundColor = MusicColor.ViewColor;
            var topView = new TopView();
            this.AddChidren(topView.TopFLayoutView());
            topView.topNameBtn.TextID = StringId.usb;
            topView.topNameBtn.TextID = StringId.localMusic;
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
@@ -31,6 +31,10 @@
                Height = Application.GetRealHeight(H_W.H - H_W.T_Height),
            };
            this.AddChidren(vv);
            vv.BeginHeaderRefreshingAction += () =>
            {
                vv.EndHeaderRefreshing();
            };
            ///加载音乐列表
            SongListView(vv, musicList, listName);
@@ -42,7 +46,7 @@
        /// <param name="vv">父控件</param>
        /// <param name="musicList">音乐列表</param>
        /// <param name="listName">列表名</param>
        public void SongListView(VerticalRefreshLayout vv,List<Songs> musicList,string listName) {
        public static void SongListView(VerticalRefreshLayout vv,List<Songs> musicList,string listName, FrameLayout frame = null) {
            for (int i = 0; i < musicList.Count; i++)
            {
@@ -65,11 +69,16 @@
                            //移除界面
                            A31MusicModel.Current.functionMusic.SetAttrState("song_name", songView.songBtn.Text);
                            A31MusicModel.Current.functionMusic.SetAttrState("playlist_name", listName);
                            //移除界面
                            if (frame != null)
                            {
                                frame.RemoveFromParent();
                            }
                            MainPage.BasePageView.RemoveViewByTag("Music");
                            Dictionary<string, string> dic = new Dictionary<string, string>();
                            dic.Add("song_name", songView.songBtn.Text);
                            dic.Add("playlist_name", listName);
                            SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic);
                            SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic);
                        });
                    });
                };
@@ -78,4 +87,63 @@
        }
    }
    public class UpdateThread
    {
        public UpdateThread()
        {
        }
        /// <summary>
        /// 定时更新当前播放音乐
        /// </summary>
        /// <param name="frame">当前界面</param>
        /// <param name="middViewLayout">每一条音乐的主控件</param>
        /// <param name="a31MusicModel">点前播放器</param>
        public static void updateCurrMusicThread(FrameLayout frame, VerticalRefreshLayout middViewLayout, A31MusicModel a31MusicModel)
        {
            System.Threading.Thread updateSelectedMusicThread = new System.Threading.Thread(() =>
            {
                while (frame.Parent != null)
                {
                    //A31MusicModel.LogMusic("已启动更新音乐列表某一条音乐状态的线程");
                    System.Threading.Thread.Sleep(1000);
                    Application.RunOnMainThread(() =>
                    {
                        try
                        {
                            for (int i = 0; i < middViewLayout.ChildrenCount; i++)
                            {
                                RowLayout view = (RowLayout)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.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString())
                                //{
                                //    volIconBtn.Visible = true;
                                //    songNameBtn.TextColor = UI.Music.MusicColor.SelectedColor;
                                //    songNameBtn.X = Application.GetRealWidth(48);
                                //    artistNameBtn.X = songNameBtn.Right;
                                //    artistNameBtn.TextColor = UI.Music.MusicColor.SelectedColor;
                                //}
                                //else
                                //{
                                //    volIconBtn.Visible = false;
                                //    songNameBtn.TextColor = UI.Music.MusicColor.MusicTxet14Color;
                                //    songNameBtn.X = Application.GetRealWidth(16);
                                //    artistNameBtn.X = songNameBtn.Right;
                                //    artistNameBtn.TextColor = UI.Music.MusicColor.MusicNoTxetColor;
                                //}
                            }
                        }
                        catch { }
                    });
                }
            });
            updateSelectedMusicThread.Start();
        }
    }
}