From e2a009ca812c2f933e195c4276b79c34ed31862a Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期五, 17 十二月 2021 18:29:10 +0800 Subject: [PATCH] 2021-12-17-01 --- HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs | 271 ++++++++++++++++++++++-------------------------------- 1 files changed, 110 insertions(+), 161 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs index d651ae9..284aadc 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs @@ -74,62 +74,67 @@ playView.collectIconBtn.IsSelected = !playView.collectIconBtn.IsSelected; if (playView.collectIconBtn.IsSelected) { - A31MusicModel.Current.collect = true; + A31MusicModel.Current.functionMusic.collect = true; } else { - A31MusicModel.Current.collect = false; + A31MusicModel.Current.functionMusic.collect = false; } }; //蹇繘婊戝姩寮硅捣浜嬩欢; playView.diyArcSeekBar.OnStopTrackingTouchEvent+= (sender, e) => { - int totalSecond = (int)(playView.diyArcSeekBar.Progress * 1.0f / 100 * int.Parse(A31MusicModel.Current.A31PlayStatus.totlen) / 1000); + 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); + //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) { - //0鍒楄〃寰幆锛�1鍗曟洸寰幆锛�2闅忔満鎾斁; - case "0": - A31MusicModel.Current.A31PlayStatus.loop = "1"; + //list_cycle鍒楄〃寰幆锛宻ingle_cycle鍗曟洸寰幆锛宺andom闅忔満鎾斁; + case "list_cycle": + modeValueString="single_cycle"; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; msg += Language.StringByID(StringId.singleMode); break; - case "1": - A31MusicModel.Current.A31PlayStatus.loop = "2"; + case "single_cycle": + modeValueString = "random"; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; msg += Language.StringByID(StringId.randomMode); break; - case "2": - A31MusicModel.Current.A31PlayStatus.loop = "0"; + case "random": + modeValueString = "list_cycle"; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; msg += Language.StringByID(StringId.listMode); break; } + A31MusicModel.Current.functionMusic.SetAttrState("mode", modeValueString); new PublicAssmebly().TipMsgAutoClose(msg, false,1000); - string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:" + "loopmode:" + A31MusicModel.Current.A31PlayStatus.loop; - SendMethod.SendCommand(url); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("mode",modeValueString); + SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic,dic); }; ///娣诲姞鍠滅埍鐐瑰嚮浜嬩欢; playView.loveBtn.MouseUpEventHandler += (sender, e) => { - var url = A31MusicModel.Current.A31PlayStatus.TrackURL; - var album = A31MusicModel.Current.A31PlayStatus.Album; - var artist = A31MusicModel.Current.A31PlayStatus.Artist; - var song = A31MusicModel.Current.A31PlayStatus.Title; + 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; @@ -137,17 +142,17 @@ { if (null == A31MusicModel.Current.LoveRadioInfoList.Find((musicInfo) => { - return url == musicInfo.URL; + return name == musicInfo.name; })) { - A31MusicModel.Current.LoveRadioInfoList.Add(new MusicInfo { Title = song, URL = url, }); + A31MusicModel.Current.LoveRadioInfoList.Add(new Songs { name = name, time = songTime}); } } else { A31MusicModel.Current.LoveRadioInfoList.RemoveAll((musicInfo) => { - return url == musicInfo.URL; + return name == musicInfo.name; }); } } @@ -158,10 +163,10 @@ { if (null == A31MusicModel.Current.LoveMusicInfoList.Find((musicInfo) => { - return url == musicInfo.URL; + return name == musicInfo.name; })) { - A31MusicModel.Current.LoveMusicInfoList.Add(new MusicInfo { Title = song, URL = url, Artist = artist, Album = album }); + A31MusicModel.Current.LoveMusicInfoList.Add(new Songs { name = name, time = songTime}); } } else @@ -169,7 +174,7 @@ A31MusicModel.Current.LoveMusicInfoList.RemoveAll((musicInfo) => { //涔熻鍔犳瓕鎵嬪悕鍒ゆ柇 - return musicInfo.URL == url; + return musicInfo.name == name; }); } @@ -198,14 +203,13 @@ myListView.backIextBtn.MouseUpEventHandler += removeFromParentView; myListView.popFra.MouseUpEventHandler += removeFromParentView; #endregion - loading.Start(); - GetMusicList((listName) => - { - loading.Hide(); - PlayListView(myListView.popFra, myListView.verticalScrolViewLayout, listName); - UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout); - }); - + //var listName = A31MusicModel.Current.functionMusic.GetAttribute("playlist_name").ToString(); + //var musicList = A31MusicModel.Current.GetSongList(listName); + //new A31SongPlay { }.SongListView(myListView.verticalScrolViewLayout, musicList, listName); + + PlayListView(myListView.popFra, myListView.verticalScrolViewLayout); + UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout); + }; ///闊抽噺鍥炬爣鐐瑰嚮浜嬩欢 playView.volIconBtn.MouseUpEventHandler += (sender, e) => @@ -227,8 +231,11 @@ if (startVolume != e) { startVolume = e; - SendMethod.ControlVolume(e, A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.vol = e.ToString(); + A31MusicModel.Current.functionMusic.SetAttrState("volume", startVolume); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("volume", startVolume.ToString()); + SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + } }; playView.volSeekBar.OnProgressChangedEvent += progressClick; @@ -237,7 +244,12 @@ playView.prevBtn.MouseDownEventHandler += (sender, e) => { playView.prevBtn.IsSelected = true; - SendMethod.Previous(A31MusicModel.Current); + + A31MusicModel.Current.functionMusic.SetAttrState("song_step", "down"); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("song_step", "down"); + SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + }; playView.prevBtn.MouseUpEventHandler += (sender, e) => { @@ -246,24 +258,30 @@ ///鏆傚仠/鎾斁鐐瑰嚮浜嬩欢 playView.playBtn.MouseDownEventHandler += (sender, e) => { + string status = string.Empty; if (playView.playBtn.IsSelected) { playView.playBtn.IsSelected = false; - SendMethod.Pause(A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.status = "pause"; + status = "off"; } else { playView.playBtn.IsSelected = true; - SendMethod.Play(A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.status = "play"; + status = "on"; } + A31MusicModel.Current.functionMusic.SetAttrState("on_off", status); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("on_off", status); + SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; ///涓嬩竴鏇茬偣鍑讳簨浠� playView.nextBtn.MouseDownEventHandler += (sender, e) => { playView.nextBtn.IsSelected = true; - SendMethod.Next(A31MusicModel.Current); + A31MusicModel.Current.functionMusic.SetAttrState("song_step", "down"); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("song_step", "down"); + SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; playView.nextBtn.MouseUpEventHandler += (sender, e) => { @@ -281,8 +299,10 @@ if (startVolume != volume) { startVolume = volume; - SendMethod.ControlVolume(volume, A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.vol = volume.ToString(); + A31MusicModel.Current.functionMusic.SetAttrState("volume", startVolume); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("volume", startVolume.ToString()); + SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); } }; @@ -308,7 +328,7 @@ //鏇存柊鎬绘椂闂� //鎬诲叡鏈夊灏戠 - int totalSecond = int.Parse(A31MusicModel.Current.A31PlayStatus.totlen) / 1000; + int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState("song_time")); //鍒嗛挓 int totalMusicMinute = totalSecond / 60; //绉掗挓 @@ -319,52 +339,52 @@ //topView.topNameBtn.Text = A31MusicModel.Current.Name; - switch (A31MusicModel.Current.A31PlayStatus.loop) + switch (A31MusicModel.Current.functionMusic.GetAttrState("mode")) { - case "0"://鍒楄〃寰幆 + case "list_cycle"://鍒楄〃寰幆 playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; break; - case "1"://鍗曟洸椤虹幆 + case "single_cycle"://鍗曟洸寰幆 playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; break; - case "2"://闅忔満鎾斁 + case "random"://闅忔満鎾斁 playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; break; } - if (A31MusicModel.Current.A31PlayStatus.Source == "RADIO-NETWORK") - { - var v = A31MusicModel.Current.LoveRadioInfoList.Find((like) => - { - return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL; - }); - if (v != null) - { - playView.loveBtn.IsSelected = true; - } - else - { - playView.loveBtn.IsSelected = false; - } - } - else - { - var v = A31MusicModel.Current.LoveMusicInfoList.Find((like) => - { - return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL; - }); - if (v != null) - { - playView.loveBtn.IsSelected = true; - } - else - { - playView.loveBtn.IsSelected = false; - } - } - playView.regionBtn.Text = A31MusicModel.Current.GetRoomListName(); - if (A31MusicModel.Current.collect) + //if (A31MusicModel.Current.A31PlayStatus.Source == "RADIO-NETWORK") + //{ + // var v = A31MusicModel.Current.LoveRadioInfoList.Find((like) => + // { + // return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL; + // }); + // if (v != null) + // { + // playView.loveBtn.IsSelected = true; + // } + // else + // { + // playView.loveBtn.IsSelected = false; + // } + //} + //else + //{ + // var v = A31MusicModel.Current.LoveMusicInfoList.Find((like) => + // { + // return like.URL == A31MusicModel.Current.A31PlayStatus.TrackURL; + // }); + // if (v != null) + // { + // playView.loveBtn.IsSelected = true; + // } + // else + // { + // playView.loveBtn.IsSelected = false; + // } + //} + playView.regionBtn.Text = A31MusicModel.Current.functionMusic.GetRoomListName(); + if (A31MusicModel.Current.functionMusic.collect) { playView.collectIconBtn.IsSelected = true; } @@ -399,7 +419,7 @@ //鏇存柊鎾斁鍣ㄩ煶閲忕粰绯荤粺闊抽噺 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.functionMusic.GetAttrState("playing_time"))+ (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; int playMusicMinute = playSecond / 60; //绉掗挓 @@ -407,7 +427,7 @@ string playTime = (playMusicMinute.ToString().Length < 2 ? "0" + playMusicMinute.ToString() : playMusicMinute.ToString()) + ":" + (playMusicSecond.ToString().Length < 2 ? "0" + playMusicSecond.ToString() : playMusicSecond.ToString()); - if (A31MusicModel.Current.A31PlayStatus.status == "play") + if (A31MusicModel.Current.functionMusic.GetAttrState("on_off") == "on") { playView.playBtn.IsSelected = true; //濡傛灉鍦ㄦ挱鏀撅紝鏃堕棿灏变笉鏂彉鍖� @@ -430,10 +450,10 @@ //鍋滄鎾斁 playView.startTimeBtn.Text =playTime; } - 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()); + 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"); //鏇存柊婧愮殑鐣岄潰 - showSourcePage(); + // showSourcePage(); } catch (Exception e) { @@ -469,7 +489,7 @@ playView.diyArcSeekBar.IsClickable = true; - switch (A31MusicModel.Current.A31PlayStatus.Source) + switch (A31MusicModel.Current.functionMusic.GetAttrState("source")) { case "QPLAY"://QQ闊充箰 @@ -539,91 +559,20 @@ /// 鍔犺浇鎾斁闊充箰鍒楄〃View /// </summary> /// <param name="verticalScrolViewLayout"></param> - void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout, string playListName) + void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout) { verticalScrolViewLayout.RemoveAll(); - UI2.FuntionControlView.Music.UpdateThread.playMusuc(verticalScrolViewLayout,"鎾斁鍒楄〃", playListName, A31MusicModel.Current.CurrentPlayMusicInfoList,A31MusicModel.Current,frameLayout); + var listName = A31MusicModel.Current.functionMusic.GetAttribute("playlist_name").ToString(); + var musicList = A31MusicModel.Current.GetSongList(listName); + UI2.FuntionControlView.Music.UpdateThread.PlayMusicClick(verticalScrolViewLayout,"鎾斁鍒楄〃", listName, musicList, frameLayout); } /// <summary> /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 /// </summary> void UpdateSelectedMusic(FrameLayout frameLayout, VerticalRefreshLayout middViewLayout) { - UI2.FuntionControlView.Music.UpdateThread.updateThread(frameLayout, middViewLayout, A31MusicModel.Current); + UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(frameLayout, middViewLayout, A31MusicModel.Current); } - /// <summary> - /// 璇诲彇鎾斁闊充箰鍒楄〃 - /// </summary> - /// <param name="action"></param> - void GetMusicList(Action<string> action) { - System.Threading.Tasks.Task.Run(() => - { - string playListName = "List"; - string sourceName = "SourceName"; - try - { - if (A31MusicModel.Current.A31PlayStatus.Source == "STATION-NETWORK") - { - A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>(); - return; - } - if (A31MusicModel.Current.A31PlayStatus.Source == "AIRPLAY") - { - A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>(); - return; - } - var playString = SendMethod.GetCurrentPlayList(A31MusicModel.Current); - A31MusicModel.Current.CurrentPlayMusicInfoList = new List<MusicInfo>(); - var se = System.Security.SecurityElement.FromString(playString); - while (se.Children != null) - { - se = se.Children[0] as System.Security.SecurityElement; - } - playListName = SecurityElement.FromString(se.Text).SearchForChildByTag("ListName").Text; - sourceName = SecurityElement.FromString(se.Text).SearchForChildByTag("ListInfo").SearchForTextOfTag("SourceName"); - foreach (SecurityElement track in SecurityElement.FromString(se.Text).SearchForChildByTag("Tracks").Children) - { - MusicInfo musicInfo = new MusicInfo(); - musicInfo.URL = track.SearchForTextOfTag("URL").Replace("&", "&amp;"); - var metadata = track.SearchForTextOfTag("Metadata"); - musicInfo.SourceName = track.SearchForTextOfTag("Source"); - if (string.IsNullOrEmpty(metadata)) - { - continue; - } - if (A31MusicModel.IsJson(metadata)) - { - var qqSong = Newtonsoft.Json.JsonConvert.DeserializeObject<SendMethod.A31QQSong>(metadata); - musicInfo.Album = qqSong.album; - musicInfo.Title = qqSong.title; - musicInfo.Artist = qqSong.creator; - } - else - { - metadata = metadata.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "").Replace("&", "&amp;"); - var item = SecurityElement.FromString(metadata).SearchForChildByTag("item"); - musicInfo.Title = item.SearchForTextOfTag("dc:title"); - musicInfo.Artist = item.SearchForTextOfTag("upnp:artist"); - musicInfo.Album = item.SearchForTextOfTag("upnp:album"); - musicInfo.Duration = item.SearchForTextOfTag("res"); - musicInfo.AlbumId = item.SearchForTextOfTag("song:albumid"); - } - A31MusicModel.Current.CurrentPlayMusicInfoList.Add(musicInfo); - } - } - catch { } - finally - { - Application.RunOnMainThread(() => - { - action(playListName); - //loading.Hide(); - //PlayListView(myListView.popFra, myListView.verticalScrolViewLayout, playListName); - //UpdateSelectedMusic(myListView.popFra, myListView.verticalScrolViewLayout); - }); - } - }); - - } + } } -- Gitblit v1.8.0