From a09b0a281e9038cb137a40aec37c868654704dec Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期二, 09 六月 2020 17:33:35 +0800 Subject: [PATCH] 2020-06-09-3 --- HDL_ON/UI/Music/A31PlayMusicPage.cs | 124 ++++++++++++++++++++++++++--------------- 1 files changed, 78 insertions(+), 46 deletions(-) diff --git a/HDL_ON/UI/Music/A31PlayMusicPage.cs b/HDL_ON/UI/Music/A31PlayMusicPage.cs index 8ede9e5..4c7c132 100644 --- a/HDL_ON/UI/Music/A31PlayMusicPage.cs +++ b/HDL_ON/UI/Music/A31PlayMusicPage.cs @@ -26,15 +26,29 @@ } 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(); @@ -64,6 +78,35 @@ playView.viewFrameLayout(middLayout); #endregion + + ///鍒囨崲鎾斁妯″紡鐐瑰嚮浜嬩欢; + playView.playOrderBtn.MouseUpEventHandler += (sender, e) => + { + string msg = Language.StringByID(StringId.switchTo); + switch (A31MusicModel.Current.A31PlayStatus.loop) + { + //0鍒楄〃寰幆锛�1鍗曟洸寰幆锛�2闅忔満鎾斁; + case "0": + A31MusicModel.Current.A31PlayStatus.loop = "1"; + playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; + msg += Language.StringByID(StringId.singleMode); + break; + + case "1": + A31MusicModel.Current.A31PlayStatus.loop = "2"; + playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; + msg += Language.StringByID(StringId.randomMode); + break; + case "2": + A31MusicModel.Current.A31PlayStatus.loop = "0"; + playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; + msg += Language.StringByID(StringId.listMode); + break; + } + new PublicAssmebly().TipMsgAutoClose(msg, false,1000); + string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:" + "loopmode:" + A31MusicModel.Current.A31PlayStatus.loop; + SendMethod.SendCommand(url); + }; ///娣诲姞鍠滅埍鐐瑰嚮浜嬩欢; playView.loveBtn.MouseUpEventHandler += (sender, e) => { @@ -118,34 +161,6 @@ } A31MusicModel.Save(); }; - ///鍒囨崲鎾斁妯″紡鐐瑰嚮浜嬩欢; - playView.playOrderBtn.MouseUpEventHandler += (sender, e) => - { - string msg = Language.StringByID(StringId.switchTo); - switch (A31MusicModel.Current.A31PlayStatus.loop) - { - //0鍒楄〃寰幆锛�1鍗曟洸寰幆锛�2闅忔満鎾斁; - case "0": - A31MusicModel.Current.A31PlayStatus.loop = "1"; - playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; - msg += Language.StringByID(StringId.singleMode); - break; - - case "1": - A31MusicModel.Current.A31PlayStatus.loop = "2"; - playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; - msg += Language.StringByID(StringId.randomMode); - break; - case "2": - A31MusicModel.Current.A31PlayStatus.loop = "0"; - playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; - msg += Language.StringByID(StringId.listMode); - break; - } - new PublicAssmebly().TipMsgAutoClose(msg, false,1000); - string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:" + "loopmode:" + A31MusicModel.Current.A31PlayStatus.loop; - SendMethod.SendCommand(url); - }; ///鎴戠殑鍒楄〃鐐瑰嚮浜嬩欢 playView.playlistBtn.MouseUpEventHandler += (sender, e) => { @@ -344,16 +359,18 @@ } }; ///闊抽噺杩涘害鏉$偣鍑讳簨浠� - 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; @@ -412,6 +429,28 @@ }; } + 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> /// 瀹氭椂鏇存柊鐘舵�� @@ -422,13 +461,6 @@ { while (true) { - //if (startVolume != endVolume) - //{ - // startVolume = endVolume; - // SendMethod.ControlVolume(endVolume, A31MusicModel.Current); - // A31MusicModel.Current.A31PlayStatus.vol = endVolume.ToString(); - //} - Application.RunOnMainThread(() => { try @@ -520,8 +552,8 @@ //鏇存柊鎾斁鍣ㄩ煶閲忕粰绯荤粺闊抽噺 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; -- Gitblit v1.8.0