From 7167334c0e89dd84827d59e726123d14776e3a09 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期二, 16 六月 2020 11:14:13 +0800 Subject: [PATCH] 2020-06-16-1 --- HDL_ON/UI/Music/A31PlayMusicPage.cs | 301 +++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 247 insertions(+), 54 deletions(-) diff --git a/HDL_ON/UI/Music/A31PlayMusicPage.cs b/HDL_ON/UI/Music/A31PlayMusicPage.cs index ad84e65..b5c0cbe 100644 --- a/HDL_ON/UI/Music/A31PlayMusicPage.cs +++ b/HDL_ON/UI/Music/A31PlayMusicPage.cs @@ -14,10 +14,22 @@ public override void RemoveFromParent() { base.RemoveFromParent(); - timerThread?.Abort(); Volume.VolumeChange = null; + if (timerThread != null) + { + try + { + if (timerThread.IsAlive) + { + timerThread.Abort(); + } + } + catch { } + } + } View.PlayView playView = new View.PlayView(); + public void Show() { ///1绉掑畾鏃舵洿鏂扮姸鎬� @@ -51,6 +63,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) => { @@ -104,40 +145,7 @@ } A31MusicModel.Save(); - - ////淇濆瓨 - //string saveRoomUIName = "A31_" + A31MusicModel.Current.IPAddress; - //Shared.IO.FileUtils.WriteFileByBytes(saveRoomUIName, - //Shared.SimpleControl.CommonPage.MyEncodingUTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(A31MusicModel.Current))); }; - ///鍒囨崲鎾斁妯″紡鐐瑰嚮浜嬩欢; - 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); - string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:" + "loopmode:" + A31MusicModel.Current.A31PlayStatus.loop; - SendMethod.SendCommand(url); - }; ///鎴戠殑鍒楄〃鐐瑰嚮浜嬩欢 playView.playlistBtn.MouseUpEventHandler += (sender, e) => { @@ -156,7 +164,7 @@ Width = Application.GetRealWidth(344), Height = Application.GetRealHeight(460), BackgroundColor = Color.WhiteColor, - Radius=(uint)Application.GetRealHeight(12), + Radius = (uint)Application.GetRealHeight(12), }; popFra.AddChidren(dialogFra); dialogFra.AddChidren(loading);//dialogFra鍒锋柊鍥炬爣鐖舵帶浠� @@ -210,7 +218,7 @@ Y = Application.GetRealHeight(15), Width = Application.GetRealWidth(28 + 12),//28 Height = Application.GetRealHeight(20), - TextID =StringId.cancelMusic, + TextID = StringId.cancelMusic, TextColor = Color.MusicNoTxetColor, TextSize = TextSize.Text14, TextAlignment = TextAlignment.CenterLeft, @@ -234,11 +242,20 @@ ///绉婚櫎鐣岄潰 EventHandler<MouseEventArgs> removeFromParentView = (sen, e1) => { - if (updateSelectedMusicThread != null && updateSelectedMusicThread.IsAlive) + + if (updateSelectedMusicThread != null) { - updateSelectedMusicThread.Abort(); - ///鍏抽棴绾跨▼ + try + { + if (updateSelectedMusicThread.IsAlive) + { + updateSelectedMusicThread.Abort(); + ///鍏抽棴绾跨▼ + } + } + catch { } } + popFra.RemoveFromParent(); }; backIextBtn.MouseUpEventHandler += removeFromParentView; @@ -313,13 +330,31 @@ }); }; + ///闊抽噺鍥炬爣鐐瑰嚮浜嬩欢 + playView.volIconBtn.MouseUpEventHandler += (sender, e) => + { + if (A31MusicModel.Current.ServerClientType == 1 && A31MusicModel.Current.Slave.slave_list.Count != 0) + { ///涓绘挱鏀惧櫒 + //new View.DialogView { }.PlayerVolumeView(A31MusicModel.Current); + var volumeView = new View.DialogView { }; + volumeView.PlayerVolumeView(A31MusicModel.Current); + volumeView.UpdateVolume(); + + } + }; ///闊抽噺杩涘害鏉$偣鍑讳簨浠� + int startVolume =0;//涔嬪墠鐨勯煶閲� + //int endVolume = 0;//鐜板湪鐨勯煶閲� EventHandler<int> progressClick = (sender, e) => { playView.volValueBtn.Text = playView.volSeekBar.Progress + "%"; - SendMethod.ControlVolume(playView.volSeekBar.Progress,A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.vol = playView.volSeekBar.Progress.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; @@ -332,7 +367,7 @@ playView.prevBtn.MouseUpEventHandler += (sender, e) => { playView.prevBtn.IsSelected = false; - }; + }; ///鏆傚仠/鎾斁鐐瑰嚮浜嬩欢 playView.playBtn.MouseDownEventHandler += (sender, e) => { @@ -367,12 +402,18 @@ return; } playView.volSeekBar.Progress = volume; - SendMethod.ControlVolume(playView.volSeekBar.Progress,A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.vol = playView.volSeekBar.Progress.ToString(); + + if (startVolume != volume) + { + startVolume = volume; + SendMethod.ControlVolume(volume, A31MusicModel.Current); + A31MusicModel.Current.A31PlayStatus.vol = volume.ToString(); + } + }; } - + System.Threading.Thread timerThread; /// <summary> /// 瀹氭椂鏇存柊鐘舵�� @@ -474,9 +515,8 @@ //鏇存柊鎾斁鍣ㄩ煶閲忕粰绯荤粺闊抽噺 Volume.MusicVolume = playView.volSeekBar.Progress; //褰撳墠鎾斁闊充箰鏃堕棿 - int playSecond = int.Parse(A31MusicModel.Current.A31PlayStatus.curpos) / 1000;// + (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; - //currentMusiceA31.musicPalyTime = (playSecond*10).ToString(); - //鍒嗛挓 + int playSecond = int.Parse(A31MusicModel.Current.A31PlayStatus.curpos) / 1000 + (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; + int playMusicMinute = playSecond / 60; //绉掗挓 int playMusicSecond = playSecond % 60; @@ -508,7 +548,8 @@ } playView.songNameTextView.Text = (A31MusicModel.Current.A31PlayStatus.Title == null ? "Unkown" : A31MusicModel.Current.A31PlayStatus.Title); playView.singerBtn.Text = (A31MusicModel.Current.A31PlayStatus.Artist == null ? "Unkown" : A31MusicModel.Current.A31PlayStatus.Artist.Trim()); - + //鏇存柊婧愮殑鐣岄潰 + showSourcePage(); } catch (Exception e) { @@ -520,6 +561,150 @@ }) { IsBackground = true }; timerThread.Start(); + } + /// <summary> + /// 鏇存柊涓嶅悓闊充箰婧愮晫闈㈠浘鏍囩姸鎬� + /// </summary> + void showSourcePage() + { + playView.loveBtn.Alpha = 1; + playView.loveBtn.Enable = true; + + playView.playlistBtn.Alpha = 1; + playView.playlistBtn.Enable = true; + + playView.prevBtn.Alpha = 1; + playView.prevBtn.Enable = true; + + playView.nextBtn.Alpha = 1; + playView.nextBtn.Enable = true; + + playView.playOrderBtn.Alpha = 1; + playView.playOrderBtn.Enable = true; + + //btnPlay.Alpha = 1; + //btnPlay.Enable = true; + + playView.volSeekBar.IsClickable = true; + + switch (A31MusicModel.Current.A31PlayStatus.Source) + { + + case "QPLAY"://QQ闊充箰 + //currentsource.UnSelectedImagePath = "MusicIcon/qqmusic1.png"; + playView.loveBtn.Alpha = 0.5f; + playView.loveBtn.Enable = false; + break; + case "AIRPLAY"://閰风嫍闊充箰 + //currentsource.UnSelectedImagePath = "MusicIcon/kumusic.png"; + playView.loveBtn.Alpha = 0.5f; + playView.loveBtn.Enable = false; + playView.volSeekBar.IsClickable = false; + break; + case "SONGLIST-NETWORK"://鏈湴闊充箰 + //currentsource.UnSelectedImagePath = "MusicIcon/musicMusic1.png"; + break; + case "SONGLIST-LOCAL"://USB + //currentsource.UnSelectedImagePath = "MusicIcon/USB1.png"; + break; + case "RADIO-NETWORK"://鍦ㄧ嚎鐢靛彴 + //currentsource.UnSelectedImagePath = "MusicIcon/local1.png"; + playView.playlistBtn.Alpha = 1; + playView.playlistBtn.Enable = true; + + playView.prevBtn.Alpha = 0.5f; + playView.prevBtn.Enable = false; + + playView.nextBtn.Alpha = 0.5f; + playView.nextBtn.Enable = false; + + playView.playOrderBtn.Alpha = 0.5f; + playView.playOrderBtn.Enable = false; + break; + + case "STATION-NETWORK"://Pandora鐢靛彴 + playView.volSeekBar.IsClickable = false; + //currentsource.UnSelectedImagePath = "MusicIcon/pandora1.png"; + playView.loveBtn.Alpha = 0.5f; + playView.loveBtn.Enable = false; + + playView.prevBtn.Alpha = 0.5f; + playView.prevBtn.Enable = false; + + playView.playOrderBtn.Alpha = 0.5f; + playView.playOrderBtn.Enable = false; + break; + + case "BLUETOOTH"://钃濈墮 + // currentsource.UnSelectedImagePath = "MusicIcon/bluetooth1.png"; + playView.loveBtn.Alpha = 0.5f; + playView.loveBtn.Enable = false; + + playView.playlistBtn.Alpha = 0.5f; + playView.playlistBtn.Enable = false; + + playView.prevBtn.Alpha = 0.5f; + playView.prevBtn.Enable = false; + + playView.nextBtn.Alpha = 0.5f; + playView.nextBtn.Enable = false; + + playView.playOrderBtn.Alpha = 0.5f; + playView.playOrderBtn.Enable = false; + + //btnPlay.Alpha = 0.5f; + //btnPlay.Enable = false; + break; + + + case "LINE-IN"://绾胯矾杈撳叆 + // currentsource.UnSelectedImagePath = "MusicIcon/muiscline1.png"; + playView.loveBtn.Alpha = 0.5f; + playView.loveBtn.Enable = false; + + playView.playlistBtn.Alpha = 0.5f; + playView.playlistBtn.Enable = false; + + playView.prevBtn.Alpha = 0.5f; + playView.prevBtn.Enable = false; + + playView.nextBtn.Alpha = 0.5f; + playView.nextBtn.Enable = false; + + playView.playOrderBtn.Alpha = 0.5f; + playView.playOrderBtn.Enable = false; + + //btnPlay.Alpha = 0.5f; + //btnPlay.Enable = false; + break; + + default: + //currentsource.UnSelectedImagePath = "MusicIcon/dlna.png"; + playView.volSeekBar.IsClickable = false; + playView.loveBtn.Alpha = 0.5f; + playView.loveBtn.Enable = false; + + playView.playlistBtn.Alpha = 0.5f; + playView.playlistBtn.Enable = false; + + playView.prevBtn.Alpha = 0.5f; + playView.prevBtn.Enable = false; + + playView.nextBtn.Alpha = 0.5f; + playView.nextBtn.Enable = false; + + playView.playOrderBtn.Alpha = 0.5f; + playView.playOrderBtn.Enable = false; + break; + } + //if (A31MusicModel.Current.A31PlayStatus.playSource == "UPnPServer") + //{ + // currentsource.UnSelectedImagePath = "MusicIcon/dlna.png"; + //} + //else if (A31MusicModel.Current.A31PlayStatus.playSource == "Tidal") + //{ + // currentsource.UnSelectedImagePath = "MusicIcon/Tidal1.png"; + //} } /// <summary> /// 鏄剧ず褰撳墠鎾斁闊充箰View @@ -621,10 +806,17 @@ ///鐐瑰嚮鎾斁浜嬩欢 clickBtn.MouseUpEventHandler += (sender, e) => { - if (updateSelectedMusicThread != null && updateSelectedMusicThread.IsAlive) + if (updateSelectedMusicThread != null) { - updateSelectedMusicThread.Abort(); - ///鍏抽棴绾跨▼ + try + { + if (updateSelectedMusicThread.IsAlive) + { + updateSelectedMusicThread.Abort(); + ///鍏抽棴绾跨▼ + } + } + catch { } } System.Threading.Tasks.Task.Run(() => { @@ -636,7 +828,7 @@ A31MusicModel.Current.A31PlayStatus.Title = songBtn.Text; System.Threading.Tasks.Task.Run(() => { - SendMethod.ListMusicPlay(playListName, clickBtn.Tag,A31MusicModel.Current); + SendMethod.ListMusicPlay(playListName, clickBtn.Tag, A31MusicModel.Current); }); }); }); @@ -690,7 +882,8 @@ }); } - }); + }) + { IsBackground = true }; updateSelectedMusicThread.Start(); } } -- Gitblit v1.8.0