陈嘉乐
2020-06-10 a7d20263f28aa009ef8e064a7f9700d7cd642492
HDL_ON/UI/Music/A31PlayMusicPage.cs
@@ -26,29 +26,14 @@
                }
                catch { }
            }
            if (VolumeThread != null)
            {
                try
                {
                    if (VolumeThread.IsAlive)
                    {
                        VolumeThread.Abort();
                    }
                }
                catch { }
            }
        }
        View.PlayView playView = new View.PlayView();
        int startVolume = 0;//之前的音量
        int endVolume = 0;//现在的音量
        public void Show()
        {
            ///1秒定时更新状态
            timerUpdateStatus();
            ///0.5秒监听音量状态
            VolumeUpdateSend();
            #region   ---界面布局---
            this.BackgroundColor = Color.ViewColor;
            var topView = new TopView();
@@ -359,18 +344,17 @@
                }
            };
            ///音量进度条点击事件
            //int startVolume =0;//之前的音量
            //int endVolume = 0;
            int startVolume =0;//之前的音量
            //int endVolume = 0;//现在的音量
            EventHandler<int> progressClick = (sender, e) =>
            {
                playView.volValueBtn.Text = playView.volSeekBar.Progress + "%";
                endVolume = e;
                //if (startVolume != e)
                //{
                //    startVolume = e;
                //    SendMethod.ControlVolume(e, A31MusicModel.Current);
                //    A31MusicModel.Current.A31PlayStatus.vol = e.ToString();
                //}
                if (startVolume != e)
                {
                    startVolume = e;
                    SendMethod.ControlVolume(e, A31MusicModel.Current);
                    A31MusicModel.Current.A31PlayStatus.vol = e.ToString();
                }
            };
            playView.volSeekBar.OnProgressChangedEvent += progressClick;
            playView.volSeekBar.OnStopTrackingTouchEvent += progressClick;
@@ -429,28 +413,7 @@
            };
        }
        System.Threading.Thread VolumeThread;
        /// <summary>
        /// 音量发送
        /// </summary>
        void VolumeUpdateSend()
        {
            VolumeThread = new System.Threading.Thread((obj) =>
            {
                while (true)
                {
                    if (startVolume != endVolume)
                    {
                        startVolume = endVolume;
                        SendMethod.ControlVolume(endVolume, A31MusicModel.Current);
                        A31MusicModel.Current.A31PlayStatus.vol = endVolume.ToString();
                    }
                    System.Threading.Thread.Sleep(300);
                }
            })
            { IsBackground = true };
            VolumeThread.Start();
        }
        System.Threading.Thread timerThread;
        /// <summary>
        /// 定时更新状态