From 52c945d6f5628e7fac328a5df8bc295ccfc5966b Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期一, 10 一月 2022 20:53:54 +0800 Subject: [PATCH] 2021-1-10-01 --- HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs | 195 ++++++++++++++++++++++-------------------------- 1 files changed, 90 insertions(+), 105 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs index 5a8636c..855e266 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs @@ -3,6 +3,7 @@ using com.hdl.on; using System.Collections.Generic; using System.Security; +using HDL_ON.UI.UI2.FuntionControlView.Music; namespace HDL_ON.UI.Music { @@ -36,17 +37,18 @@ /// new甯冨眬鐣岄潰 /// </summary> View.PlayView playView = new View.PlayView(); - + TopView topView; + + public void Show() { ///1绉掑畾鏃舵洿鏂扮姸鎬� timerUpdateStatus(); #region ---鐣岄潰甯冨眬--- this.BackgroundColor = MusicColor.ViewColor; - var topView = new TopView(); + topView = new TopView(); topView.setBtn.Visible = true; this.AddChidren(topView.TopFLayoutView()); - topView.topNameBtn.Text = A31MusicModel.Current.Name; topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); @@ -82,52 +84,36 @@ } }; - //蹇繘婊戝姩寮硅捣浜嬩欢; - playView.diyArcSeekBar.OnStopTrackingTouchEvent+= (sender, e) => - { - //int totalSecond = (int)(playView.diyArcSeekBar.Progress * 1.0f / 100 * int.Parse(A31MusicModel.Current.functionMusic.GetAttrState("song_time"))); - ////鍒嗛挓 - //int Minute = totalSecond / 60; - ////绉掗挓 - //int Second = totalSecond % 60; - //string time = "00" + ":" + (Minute.ToString().Length < 2 ? "0" + Minute.ToString() : Minute.ToString()) + ":" + (Second.ToString().Length < 2 ? "0" + Second.ToString() : Second.ToString()); - //SendMethod.Seek(time, A31MusicModel.Current); - - //Dictionary<string, string> dic = new Dictionary<string, string>(); - //dic.Add("mode", modeValueString); - //SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); - // A31MusicModel.Current.A31PlayStatus.curpos = (DateTime.Parse(time) - DateTime.Parse("00:00:00")).TotalMilliseconds.ToString(); - }; ///鍒囨崲鎾斁妯″紡鐐瑰嚮浜嬩欢; playView.playOrderBtn.MouseUpEventHandler += (sender, e) => { string modeValueString = string.Empty; string msg = Language.StringByID(StringId.switchTo); - switch (A31MusicModel.Current.A31PlayStatus.loop) + switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode)) { //list_cycle鍒楄〃寰幆锛宻ingle_cycle鍗曟洸寰幆锛宺andom闅忔満鎾斁; - case "list_cycle": - modeValueString="single_cycle"; + case ValueProperty.list_cycle: + modeValueString=ValueProperty.single_cycle; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; msg += Language.StringByID(StringId.singleMode); break; - case "single_cycle": - modeValueString = "random"; + case ValueProperty.single_cycle: + modeValueString =ValueProperty.random; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; msg += Language.StringByID(StringId.randomMode); break; - case "random": - modeValueString = "list_cycle"; + case ValueProperty.random: + modeValueString = ValueProperty.list_cycle; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; msg += Language.StringByID(StringId.listMode); break; } - A31MusicModel.Current.functionMusic.SetAttrState("mode", modeValueString); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.mode, modeValueString); new PublicAssmebly().TipMsgAutoClose(msg, false,1000); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("mode",modeValueString); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic,dic); + dic.Add(KeyProperty.mode,modeValueString); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic,dic); }; ///娣诲姞鍠滅埍鐐瑰嚮浜嬩欢; playView.loveBtn.MouseUpEventHandler += (sender, e) => @@ -135,49 +121,24 @@ var name = A31MusicModel.Current.functionMusic.GetAttribute("song_name").ToString(); var songTime = A31MusicModel.Current.functionMusic.GetAttribute("song_time").ToString(); - if (A31MusicModel.Current.A31PlayStatus.Source == "RADIO-NETWORK") + playView.loveBtn.IsSelected = !playView.loveBtn.IsSelected; + if (playView.loveBtn.IsSelected) { - playView.loveBtn.IsSelected = !playView.loveBtn.IsSelected; - if (playView.loveBtn.IsSelected) + if (null == A31MusicModel.Current.LoveMusicInfoList.Find((musicInfo) => { - if (null == A31MusicModel.Current.LoveRadioInfoList.Find((musicInfo) => - { - return name == musicInfo.name; - })) - { - A31MusicModel.Current.LoveRadioInfoList.Add(new Songs { name = name, time = songTime}); - } - } - else + return name == musicInfo.name; + })) { - A31MusicModel.Current.LoveRadioInfoList.RemoveAll((musicInfo) => - { - return name == musicInfo.name; - }); + A31MusicModel.Current.LoveMusicInfoList.Add(new Songs { name = name, time = songTime }); } } else { - playView.loveBtn.IsSelected = !playView.loveBtn.IsSelected; - if (playView.loveBtn.IsSelected) + A31MusicModel.Current.LoveMusicInfoList.RemoveAll((musicInfo) => { - if (null == A31MusicModel.Current.LoveMusicInfoList.Find((musicInfo) => - { - return name == musicInfo.name; - })) - { - A31MusicModel.Current.LoveMusicInfoList.Add(new Songs { name = name, time = songTime}); - } - } - else - { - A31MusicModel.Current.LoveMusicInfoList.RemoveAll((musicInfo) => - { - //涔熻鍔犳瓕鎵嬪悕鍒ゆ柇 - return musicInfo.name == name; - }); - } - + //涔熻鍔犳瓕鎵嬪悕鍒ゆ柇 + return musicInfo.name == name; + }); } A31MusicModel.Save(); }; @@ -214,13 +175,7 @@ ///闊抽噺鍥炬爣鐐瑰嚮浜嬩欢 playView.volIconBtn.MouseUpEventHandler += (sender, e) => { - if (A31MusicModel.Current.ServerClientType == 1 && A31MusicModel.Current.Slave.slave_list.Count != 0) - { ///涓绘挱鏀惧櫒 - var volumeView = new View.DialogView { }; - volumeView.PlayerVolumeView(A31MusicModel.Current); - volumeView.UpdateVolume(); - - } + }; ///闊抽噺杩涘害鏉$偣鍑讳簨浠� int startVolume =0;//涔嬪墠鐨勯煶閲� @@ -231,10 +186,10 @@ if (startVolume != e) { startVolume = e; - A31MusicModel.Current.functionMusic.SetAttrState("volume", startVolume); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("volume", startVolume.ToString()); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + dic.Add(KeyProperty.volume, startVolume.ToString()); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); } }; @@ -245,10 +200,10 @@ { playView.prevBtn.IsSelected = true; - A31MusicModel.Current.functionMusic.SetAttrState("song_step", "down"); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step,ValueProperty.down); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("song_step", "down"); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + dic.Add(KeyProperty.song_step, ValueProperty.down); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; playView.prevBtn.MouseUpEventHandler += (sender, e) => @@ -262,26 +217,26 @@ if (playView.playBtn.IsSelected) { playView.playBtn.IsSelected = false; - status = "off"; + status = ValueProperty.off; } else { playView.playBtn.IsSelected = true; - status = "on"; + status = ValueProperty.on; } - A31MusicModel.Current.functionMusic.SetAttrState("on_off", status); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.on_off, status); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("on_off", status); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + dic.Add(KeyProperty.on_off, status); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; ///涓嬩竴鏇茬偣鍑讳簨浠� playView.nextBtn.MouseDownEventHandler += (sender, e) => { playView.nextBtn.IsSelected = true; - A31MusicModel.Current.functionMusic.SetAttrState("song_step", "down"); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step,ValueProperty.down); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("song_step", "down"); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + dic.Add(KeyProperty.song_step, ValueProperty.down); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; playView.nextBtn.MouseUpEventHandler += (sender, e) => { @@ -290,7 +245,7 @@ ///鐗╃悊鎸夐敭鐨勭偣鍑讳簨浠� Volume.VolumeChange = (volume) => { - if (Application.DeviceType == Device.Ios && A31MusicModel.Current.A31PlayStatus.Source == "BLUETOOTH") + if (Application.DeviceType == Device.Ios && A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source) == "bluetooth") { return; } @@ -299,10 +254,10 @@ if (startVolume != volume) { startVolume = volume; - A31MusicModel.Current.functionMusic.SetAttrState("volume", startVolume); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("volume", startVolume.ToString()); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + dic.Add(KeyProperty.volume, startVolume.ToString()); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); } }; @@ -325,10 +280,9 @@ { try { - //鏇存柊鎬绘椂闂� //鎬诲叡鏈夊灏戠 - int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState("song_time")); + int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_time))/1000; //鍒嗛挓 int totalMusicMinute = totalSecond / 60; //绉掗挓 @@ -337,17 +291,17 @@ 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.Name; + topView.topNameBtn.Text = A31MusicModel.Current.functionMusic.name; - switch (A31MusicModel.Current.functionMusic.GetAttrState("mode")) + switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode)) { - case "list_cycle"://鍒楄〃寰幆 + case ValueProperty.list_cycle://鍒楄〃寰幆 playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; break; - case "single_cycle"://鍗曟洸寰幆 + case ValueProperty.single_cycle://鍗曟洸寰幆 playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; break; - case "random"://闅忔満鎾斁 + case ValueProperty.random://闅忔満鎾斁 playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; break; } @@ -412,15 +366,15 @@ if (1000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds) { //闊抽噺杩涘害鏉�; - playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.A31PlayStatus.vol); + playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume)); //鏄剧ず褰撳墠闊抽噺鍊�; - playView.volValueBtn.Text = A31MusicModel.Current.A31PlayStatus.vol + "%"; + 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("playing_time"))+ (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; + int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playing_time))/1000+ (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; int playMusicMinute = playSecond / 60; //绉掗挓 @@ -428,7 +382,7 @@ string playTime = (playMusicMinute.ToString().Length < 2 ? "0" + playMusicMinute.ToString() : playMusicMinute.ToString()) + ":" + (playMusicSecond.ToString().Length < 2 ? "0" + playMusicSecond.ToString() : playMusicSecond.ToString()); - if (A31MusicModel.Current.functionMusic.GetAttrState("on_off") == "on") + if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on) { playView.playBtn.IsSelected = true; //濡傛灉鍦ㄦ挱鏀撅紝鏃堕棿灏变笉鏂彉鍖� @@ -444,6 +398,8 @@ playView.diyArcSeekBar.Progress = (int)(playSecond * 100.0 / totalSecond);//+1 } + Console.WriteLine("鎵撳嵃鏃堕棿======"+playTime); + } else { @@ -451,8 +407,8 @@ //鍋滄鎾斁 playView.startTimeBtn.Text =playTime; } - playView.songNameTextView.Text = A31MusicModel.Current.functionMusic.GetAttrState("song_name") == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState("song_name"); - playView.singerBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState("song_name") == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState("song_name"); + 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(); } @@ -563,16 +519,45 @@ void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout) { verticalScrolViewLayout.RemoveAll(); - var listName = A31MusicModel.Current.functionMusic.GetAttribute("playlist_name").ToString(); + var listName = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playlist_name); var musicList = A31MusicModel.Current.GetSongList(listName); - UI2.FuntionControlView.Music.UpdateThread.PlayMusicClick(verticalScrolViewLayout,"鎾斁鍒楄〃", listName, musicList, frameLayout); + if (musicList.Count == 0) + { + System.Threading.Tasks.Task.Run(() => + { + try + { + A31MusicModel.Current.palyLists.Clear(); + if (A31MusicModel.Current.palyLists.Count == 0) + { + SendMethod.mMethod.GetPalyList(A31MusicModel.Current.functionMusic); + + } + } + catch + { + } + finally + { + Application.RunOnMainThread(() => + { + musicList = A31MusicModel.Current.GetSongList(listName); + A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, frameLayout); + }); + } + }); + } + else + { + A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, frameLayout); + } } /// <summary> /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 /// </summary> void UpdateSelectedMusic(FrameLayout frameLayout, VerticalRefreshLayout middViewLayout) { - UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(frameLayout, middViewLayout, A31MusicModel.Current); + UpdateThread.updateCurrMusicThread(frameLayout, middViewLayout, A31MusicModel.Current); } } -- Gitblit v1.8.0