mac
2024-07-25 f9181a9c8125136f597add7c30cb2ff508d54ba7
2024年07月25日17:33:40

强制线程终止,导致线程在运行报错;
4个文件已修改
464 ■■■■ 已修改文件
HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs 336 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/FuntionControlView/Music/A31SongPlay.cs 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
NunitTest-Android/Resources/Resource.designer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs
@@ -349,182 +349,186 @@
        {
            timerThread = new System.Threading.Thread((obj) =>
            {
                while (true)
                try
                {
                    Application.RunOnMainThread(() =>
                    while (true)
                    {
                        try
                        Application.RunOnMainThread(() =>
                        {
                            //更新总时间
                            //总共有多少秒
                            int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_time));
                            //分钟
                            int totalMusicMinute = totalSecond / 60;
                            //秒钟
                            int totalMusicSecond = totalSecond % 60;
                            //转化歌曲总时间时间格式
                            string totalTime = (totalMusicMinute.ToString().Length < 2 ? "0" + totalMusicMinute.ToString() : totalMusicMinute.ToString()) + ":" + (totalMusicSecond.ToString().Length < 2 ? "0" + totalMusicSecond.ToString() : totalMusicSecond.ToString());
                            //显示总时间
                            playView.endTimeBtn.Text = totalTime;
                            //显示播放器名称
                            topView.topNameBtn.Text = A31MusicModel.Current.functionMusic.name;
                            //显示播放模式图标
                            switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode))
                            try
                            {
                                case ValueProperty.list_cycle://列表循环
                                    playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png";
                                    break;
                                case ValueProperty.single_cycle://单曲循环
                                    playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single_cycle.png";
                                    break;
                                case ValueProperty.random://随机播放
                                    playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png";
                                    break;
                                case ValueProperty.single:// 单曲<single>
                                    playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png";
                                    break;
                                case ValueProperty.order://循序循环
                                    playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/order.png";
                                    break;
                            }
                                //更新总时间
                                //总共有多少秒
                                int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_time));
                                //分钟
                                int totalMusicMinute = totalSecond / 60;
                                //秒钟
                                int totalMusicSecond = totalSecond % 60;
                                //转化歌曲总时间时间格式
                                string totalTime = (totalMusicMinute.ToString().Length < 2 ? "0" + totalMusicMinute.ToString() : totalMusicMinute.ToString()) + ":" + (totalMusicSecond.ToString().Length < 2 ? "0" + totalMusicSecond.ToString() : totalMusicSecond.ToString());
                                //显示总时间
                                playView.endTimeBtn.Text = totalTime;
                                //显示播放器名称
                                topView.topNameBtn.Text = A31MusicModel.Current.functionMusic.name;
                                //显示播放模式图标
                                switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode))
                                {
                                    case ValueProperty.list_cycle://列表循环
                                        playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png";
                                        break;
                                    case ValueProperty.single_cycle://单曲循环
                                        playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single_cycle.png";
                                        break;
                                    case ValueProperty.random://随机播放
                                        playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png";
                                        break;
                                    case ValueProperty.single:// 单曲<single>
                                        playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png";
                                        break;
                                    case ValueProperty.order://循序循环
                                        playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/order.png";
                                        break;
                                }
                            //if (A31MusicModel.Current.A31PlayStatus.Source == "RADIO-NETWORK")
                            //{
                            //    var v = A31MusicModel.Current.LoveRadioInfoList.Find((like) =>
                            //    {
                            //        return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL;
                            //    });
                            //    if (v != null)
                            //    {
                            //        playView.loveBtn.IsSelected = true;
                            //    }
                            //    else
                            //    {
                            //        playView.loveBtn.IsSelected = false;
                            //    }
                            //}
                            //else
                            //{
                            //    var v = A31MusicModel.Current.LoveMusicInfoList.Find((like) =>
                            //    {
                            //        return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL;
                            //    });
                            //    if (v != null)
                            //    {
                            //        playView.loveBtn.IsSelected = true;
                            //    }
                            //    else
                            //    {
                            //        playView.loveBtn.IsSelected = false;
                            //    }
                            //}
                            //显示播放器区域
                            playView.regionBtn.Text = A31MusicModel.Current.functionMusic.GetRoomListName();
                            //显示播放器收藏状态
                            if (A31MusicModel.Current.functionMusic.collect)
                            {
                                //收藏
                                playView.collectIconBtn.IsSelected = true;
                                //if (A31MusicModel.Current.A31PlayStatus.Source == "RADIO-NETWORK")
                                //{
                                //    var v = A31MusicModel.Current.LoveRadioInfoList.Find((like) =>
                                //    {
                                //        return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL;
                                //    });
                                //    if (v != null)
                                //    {
                                //        playView.loveBtn.IsSelected = true;
                                //    }
                                //    else
                                //    {
                                //        playView.loveBtn.IsSelected = false;
                                //    }
                                //}
                                //else
                                //{
                                //    var v = A31MusicModel.Current.LoveMusicInfoList.Find((like) =>
                                //    {
                                //        return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL;
                                //    });
                                //    if (v != null)
                                //    {
                                //        playView.loveBtn.IsSelected = true;
                                //    }
                                //    else
                                //    {
                                //        playView.loveBtn.IsSelected = false;
                                //    }
                                //}
                                //显示播放器区域
                                playView.regionBtn.Text = A31MusicModel.Current.functionMusic.GetRoomListName();
                                //显示播放器收藏状态
                                if (A31MusicModel.Current.functionMusic.collect)
                                {
                                    //收藏
                                    playView.collectIconBtn.IsSelected = true;
                                }
                                else
                                {
                                    //不收藏
                                    playView.collectIconBtn.IsSelected = false;
                                }
                                //if (A31MusicModel.Current.A31PlayStatus.IsMute)
                                //{
                                //   // btnMute.IsSelected = true;//静音图标
                                //    playView.volSeekBar.Progress = 0;
                                //}
                                //else
                                //{
                                //   // btnMute.IsSelected = false;//静音图标
                                //    if (1000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds)
                                //    {
                                //        //声音进度条;
                                //        playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.A31PlayStatus.vol);
                                //        //显示当前音量值;
                                //        playView.volValueBtn.Text = A31MusicModel.Current.A31PlayStatus.vol + "%";
                                //    }
                                //}
                                //为了防止音量条跳动,延长更新时间(多加1s)
                                if (2000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds || A31MusicModel.ProgressDateTime == DateTime.MinValue)
                                {
                                    //显示音量进度条值;
                                    playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume));
                                    //显示当前音量值;
                                    playView.volValueBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume) + "%";
                                }
                                //更新播放器音量给系统音量
                                //Volume.MusicVolume = playView.volSeekBar.Progress;
                                //当前播放音乐时间
                                //按道理不会为空,GetAttrState("playing_time")值可能为空,强制转换int.Parse()会出现异常,不过也做了异常处理了
                                int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playing_time));
                                //识别音乐状态是否在播放状态
                                if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on)
                                {
                                    //音乐在播放时,再计算播放时间(现在时间=原来时间+1秒)
                                    //playSecond += (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds;
                                    playSecond += 1;//表示加上等待的时间1s
                                    ///歌曲记录暂时时间写入缓存;
                                    A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.playing_time, playSecond);
                                }
                                if (playSecond <= 0)
                                {
                                    ///播放时间不能小于0;
                                    playSecond = 0;
                                }
                                if (playSecond >= totalSecond)
                                {
                                    ///播放时间不能超过总时间;
                                    playSecond = totalSecond;
                                }
                                int playMusicMinute = playSecond / 60;
                                //秒钟
                                int playMusicSecond = playSecond % 60;
                                //转化播放时间时间格式
                                string playTime = (playMusicMinute.ToString().Length < 2 ? "0" + playMusicMinute.ToString() : playMusicMinute.ToString()) + ":" + (playMusicSecond.ToString().Length < 2 ? "0" + playMusicSecond.ToString() : playMusicSecond.ToString());
                                //显示播放时间
                                playView.startTimeBtn.Text = playTime;
                                //显示播放状态
                                if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on)
                                {
                                    //播放
                                    playView.playBtn.IsSelected = true;
                                }
                                else
                                {
                                    //暂停
                                    playView.playBtn.IsSelected = false;
                                    ///记录歌曲暂停时间;<LastDateTime 计算播放时间有用到>
                                    A31MusicModel.Current.LastDateTime = DateTime.Now;
                                }
                                //显示进度条值
                                if (totalSecond == 0)
                                {
                                    //歌曲播放进度
                                    playView.diyArcSeekBar.Progress = 0;
                                }
                                else
                                {
                                    //歌曲播放进度
                                    playView.diyArcSeekBar.Progress = (int)(playSecond * 100.0 / totalSecond);//+1
                                }
                                //显示歌曲名称
                                playView.songNameTextView.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name) == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name);
                                //显示歌手名称
                                playView.singerBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name) == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name);
                                //更新源的界面
                                // showSourcePage();
                            }
                            else
                            catch (Exception e)
                            {
                                //不收藏
                                playView.collectIconBtn.IsSelected = false;
                                var ee = e.Message;
                            }
                            //if (A31MusicModel.Current.A31PlayStatus.IsMute)
                            //{
                            //   // btnMute.IsSelected = true;//静音图标
                            //    playView.volSeekBar.Progress = 0;
                            //}
                            //else
                            //{
                            //   // btnMute.IsSelected = false;//静音图标
                            //    if (1000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds)
                            //    {
                            //        //声音进度条;
                            //        playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.A31PlayStatus.vol);
                            //        //显示当前音量值;
                            //        playView.volValueBtn.Text = A31MusicModel.Current.A31PlayStatus.vol + "%";
                            //    }
                            //}
                            //为了防止音量条跳动,延长更新时间(多加1s)
                            if (2000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds || A31MusicModel.ProgressDateTime == DateTime.MinValue)
                            {
                                //显示音量进度条值;
                                playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume));
                                //显示当前音量值;
                                playView.volValueBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume) + "%";
                            }
                            //更新播放器音量给系统音量
                            //Volume.MusicVolume = playView.volSeekBar.Progress;
                            //当前播放音乐时间
                            //按道理不会为空,GetAttrState("playing_time")值可能为空,强制转换int.Parse()会出现异常,不过也做了异常处理了
                            int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playing_time));
                            //识别音乐状态是否在播放状态
                            if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on)
                            {
                                //音乐在播放时,再计算播放时间(现在时间=原来时间+1秒)
                                //playSecond += (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds;
                                playSecond += 1;//表示加上等待的时间1s
                                ///歌曲记录暂时时间写入缓存;
                                A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.playing_time, playSecond);
                            }
                            if (playSecond <= 0)
                            {
                                ///播放时间不能小于0;
                                playSecond = 0;
                            }
                            if (playSecond >= totalSecond)
                            {
                                ///播放时间不能超过总时间;
                                playSecond = totalSecond;
                            }
                            int playMusicMinute = playSecond / 60;
                            //秒钟
                            int playMusicSecond = playSecond % 60;
                            //转化播放时间时间格式
                            string playTime = (playMusicMinute.ToString().Length < 2 ? "0" + playMusicMinute.ToString() : playMusicMinute.ToString()) + ":" + (playMusicSecond.ToString().Length < 2 ? "0" + playMusicSecond.ToString() : playMusicSecond.ToString());
                            //显示播放时间
                            playView.startTimeBtn.Text = playTime;
                            //显示播放状态
                            if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on)
                            {
                                //播放
                                playView.playBtn.IsSelected = true;
                            }
                            else
                            {
                                //暂停
                                playView.playBtn.IsSelected = false;
                                ///记录歌曲暂停时间;<LastDateTime 计算播放时间有用到>
                                A31MusicModel.Current.LastDateTime = DateTime.Now;
                            }
                            //显示进度条值
                            if (totalSecond == 0)
                            {
                                //歌曲播放进度
                                playView.diyArcSeekBar.Progress = 0;
                            }
                            else
                            {
                                //歌曲播放进度
                                playView.diyArcSeekBar.Progress = (int)(playSecond * 100.0 / totalSecond);//+1
                            }
                            //显示歌曲名称
                            playView.songNameTextView.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name) == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name);
                            //显示歌手名称
                            playView.singerBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name) == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name);
                            //更新源的界面
                            // showSourcePage();
                        }
                        catch (Exception e)
                        {
                            var ee = e.Message;
                        }
                    });
                    System.Threading.Thread.Sleep(1000 * 1);
                        });
                        System.Threading.Thread.Sleep(1000 * 1);
                    }
                }
                catch (Exception e) { }
            })
            { IsBackground = true };
            timerThread.Start();
HDL_ON/UI/UI2/FuntionControlView/Music/A31SongPlay.cs
@@ -140,44 +140,48 @@
        {
            System.Threading.Thread updateSelectedMusicThread = new System.Threading.Thread(() =>
            {
                while (frame.Parent != null)
                try
                {
                    //A31MusicModel.LogMusic("已启动更新音乐列表某一条音乐状态的线程");
                    System.Threading.Thread.Sleep(1000);
                    Application.RunOnMainThread(() =>
                    while (frame.Parent != null)
                    {
                        try
                        //A31MusicModel.LogMusic("已启动更新音乐列表某一条音乐状态的线程");
                        System.Threading.Thread.Sleep(1000);
                        Application.RunOnMainThread(() =>
                        {
                            for (int i = 0; i < middViewLayout.ChildrenCount; i++)
                            try
                            {
                                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;
                                //}
                                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 { }
                            catch { }
                    });
                        });
                    }
                }
                catch (Exception e) { }
            });
            updateSelectedMusicThread.Start();
        }
HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs
@@ -276,41 +276,49 @@
            //更新状态线程
            var musicThread = new System.Threading.Thread(() =>
            {
                while (true)
                try
                {
                    if (!player.functionMusic.isOnline())
                    while (true)
                    {
                        ///不在线不读状态
                        continue;
                    }
                    //SendMethod.ReadStatus(player);
                    SendMethod.Current.GetDeviceStatus(ref player, new List<string> { player.functionMusic.deviceId }, player.functionMusic.sid);
                    System.Threading.Thread.Sleep(1000);
                    Application.RunOnMainThread(() =>
                    {
                        musicView.singerBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name);
                        musicView.songNameBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name);
                        musicView.musicNameBtn.Text = player.functionMusic.name;
                        if (player.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on)
                        if (!player.functionMusic.isOnline())
                        {
                            musicView.playBtn.IsSelected = true;
                            ///不在线不读状态
                            continue;
                        }
                        else
                        //SendMethod.ReadStatus(player);
                        SendMethod.Current.GetDeviceStatus(ref player, new List<string> { player.functionMusic.deviceId }, player.functionMusic.sid);
                        System.Threading.Thread.Sleep(1000);
                        Application.RunOnMainThread(() =>
                        {
                            musicView.playBtn.IsSelected = false;
                        }
                        musicView.regionBtn.Text = player.functionMusic.GetRoomListName();
                            try
                            {
                                musicView.singerBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name);
                                musicView.songNameBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name);
                                musicView.musicNameBtn.Text = player.functionMusic.name;
                                if (player.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on)
                                {
                                    musicView.playBtn.IsSelected = true;
                                }
                                else
                                {
                                    musicView.playBtn.IsSelected = false;
                                }
                                musicView.regionBtn.Text = player.functionMusic.GetRoomListName();
                        if (player.functionMusic.collect)
                        {
                            musicView.collectIconBtn.IsSelected = true;
                        }
                        else
                        {
                            musicView.collectIconBtn.IsSelected = false;
                        }
                    });
                                if (player.functionMusic.collect)
                                {
                                    musicView.collectIconBtn.IsSelected = true;
                                }
                                else
                                {
                                    musicView.collectIconBtn.IsSelected = false;
                                }
                            }
                            catch (Exception e) { }
                        });
                    }
                }
                catch (Exception e) { }
            })
            { IsBackground = true, Name = "A31" };
            musicThread.Start();
NunitTest-Android/Resources/Resource.designer.cs
@@ -15,7 +15,7 @@
{
    
    
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "13.2.2.120")]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "13.2.0.99")]
    public partial class Resource
    {