| | |
| | | } |
| | | 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(); |
| | |
| | | } |
| | | }; |
| | | ///音量进度条点击事件 |
| | | int startVolume =0;//之前的音量 |
| | | //int startVolume =0;//之前的音量 |
| | | //int endVolume = 0; |
| | | EventHandler<int> progressClick = (sender, e) => |
| | | { |
| | | playView.volValueBtn.Text = playView.volSeekBar.Progress + "%"; |
| | | if (startVolume != e) |
| | | { |
| | | startVolume = e; |
| | | SendMethod.ControlVolume(e, A31MusicModel.Current); |
| | | A31MusicModel.Current.A31PlayStatus.vol = e.ToString(); |
| | | } |
| | | endVolume = e; |
| | | //if (startVolume != e) |
| | | //{ |
| | | // startVolume = e; |
| | | // SendMethod.ControlVolume(e, A31MusicModel.Current); |
| | | // A31MusicModel.Current.A31PlayStatus.vol = e.ToString(); |
| | | //} |
| | | }; |
| | | playView.volSeekBar.OnProgressChangedEvent += progressClick; |
| | | playView.volSeekBar.OnStopTrackingTouchEvent += progressClick; |
| | |
| | | }; |
| | | |
| | | } |
| | | 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> |
| | | /// 定时更新状态 |
| | |
| | | { |
| | | while (true) |
| | | { |
| | | //if (startVolume != endVolume) |
| | | //{ |
| | | // startVolume = endVolume; |
| | | // SendMethod.ControlVolume(endVolume, A31MusicModel.Current); |
| | | // A31MusicModel.Current.A31PlayStatus.vol = endVolume.ToString(); |
| | | //} |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | |
| | | //更新播放器音量给系统音量 |
| | | Volume.MusicVolume = playView.volSeekBar.Progress; |
| | | //当前播放音乐时间 |
| | | int playSecond = int.Parse(A31MusicModel.Current.A31PlayStatus.curpos) / 1000+(int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; |
| | | |
| | | int playSecond = int.Parse(A31MusicModel.Current.A31PlayStatus.curpos) / 1000 + (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; |
| | | |
| | | int playMusicMinute = playSecond / 60; |
| | | //秒钟 |
| | | int playMusicSecond = playSecond % 60; |