From 0c1b0cdf903114c4214f6b9298ecd440972a42b5 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期五, 14 一月 2022 13:13:56 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/wjc' into wxr0114 --- HDL_ON/UI/UI2/FuntionControlView/Music/View/MyListView.cs | 9 HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs | 2 HDL_ON/UI/UI2/1-HomePage/HomePage.cs | 81 HDL_ON/UI/UI2/FuntionControlView/Music/View/PlayView.cs | 13 HDL_ON/Common/ApiUtlis.cs | 3 HDL_ON/UI/UI2/FuntionControlView/Music/View/DialogView.cs | 1241 ---------------- HDL_ON/HDL_ON.projitems | 45 HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs | 922 +----------- HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs | 12 HDL_ON/UI/UI2/FuntionControlView/Music/View/SongView.cs | 29 HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicSourcePage.cs | 221 -- HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs | 371 ++-- HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicFileList.cs | 115 + HDL_ON/UI/UI2/FuntionControlView/Music/View/MusicView.cs | 15 HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs | 7 HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs | 4 HDL_ON/DAL/DriverLayer/Control.cs | 22 HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs | 23 HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs | 2 HDL_ON/UI/UI2/FuntionControlView/Music/A31MyList.cs | 82 HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveMusicList.cs | 4 HDL_ON/UI/UI2/FuntionControlView/Music/MusicProperty.cs | 141 + HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs | 265 +-- HDL_ON/UI/UI2/FuntionControlView/Music/A31SongPlay.cs | 149 + HDL_ON/UI/UI2/FuntionControlView/Music/A31MyListMusic.cs | 4 /dev/null | 202 -- HDL_ON/DAL/Server/NewAPI.cs | 6 HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs | 2 HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs | 497 ++--- 29 files changed, 1,205 insertions(+), 3,284 deletions(-) diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs index 5ef087c..1421a8c 100644 --- a/HDL_ON/Common/ApiUtlis.cs +++ b/HDL_ON/Common/ApiUtlis.cs @@ -157,6 +157,7 @@ if (deviceResult.Code == StateCode.SUCCESS) { endTime = DateTime.Now.AddSeconds(100); + MainPage.Log($"璇诲彇璁惧淇℃伅鎴愬姛"); var deviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); if (deviceList == null) @@ -369,8 +370,6 @@ if (DB_ResidenceData.Instance.CurrentRegion != null) { #region 璇诲彇鏈湴鏁版嵁 - //璇诲彇闊充箰淇℃伅 - UI.Music.A31MusicModel.ReadMusicStates(); //鎼滅储缃戝叧 DriverLayer.Control.Ins.SearchLoaclGateway(); //閲嶆柊杩炴帴mqtt diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs index 1430b9b..277b20b 100644 --- a/HDL_ON/DAL/DriverLayer/Control.cs +++ b/HDL_ON/DAL/DriverLayer/Control.cs @@ -979,21 +979,35 @@ var localFunction = allLocalFuntion.Find((obj) => obj.sid == updateTemp.sid); if (localFunction == null) { + Console.WriteLine("鎵句笉鍒伴煶涔愭挱鏀惧櫒娣�=======" + revString); continue; } if (Ins.GatewayOnline_Local && isCloudData)//鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞� { - if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk)) + if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk) && !SPK.MusicSpkList().Contains( localFunction.spk)) { //MainPage.Log($"A鍗忚鏇存柊鐘舵��:鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�........"); + return; } } + + //if (SPK.MusicSpkList().Contains(localFunction.spk)) + //{ + // if (updateTemp.status.Count < 3) + // { + // ///鏄煶涔愬姛鑳界殑 + // ///涓婃姤灞炴�у皯3鏉′笉鍋氬鐞� + // return; + // } + //} //MainPage.Log($"A鍗忚鏇存柊鐘舵��:{revString}"); foreach (var attr in updateTemp.status) { localFunction.time_stamp = temp.time_stamp; localFunction.SetAttrState(attr.key, attr.value); + Console.WriteLine("闊充箰鎾斁鍣ㄦ坊鍔犵紦瀛樻暟鎹�=======" + revString); + } //鏇存柊鐣岄潰鐘舵�� @@ -1175,6 +1189,12 @@ //鐘舵�佹洿鏂� Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status); break; + case SPK.AvMusic: + case SPK.MusicStandard: + //UI.Music.MusicMain.mMusicMain.RefreshView(updateTemp); + Console.WriteLine("闊充箰鎾斁鍣ㄦ樉绀虹姸鎬�======="+ revString); + //wjc + break; } HomePage.UpdataFunctionStates(localFunction); diff --git a/HDL_ON/DAL/Server/NewAPI.cs b/HDL_ON/DAL/Server/NewAPI.cs index 3314fee..d1d23bb 100644 --- a/HDL_ON/DAL/Server/NewAPI.cs +++ b/HDL_ON/DAL/Server/NewAPI.cs @@ -739,6 +739,12 @@ /// </summary> public const string Api_Post_BindSourcePanel = "/home-wisdom/source/screen/home/bind"; + #region 鈻� -- 闊充箰鐩稿叧鎺ュ彛_______________________________ + /// <summary> + /// 鑾峰彇闊充箰鍒楄〃 + /// </summary> + public const string Api_Post_PlayerList = "/home-wisdom/app/wise/music/playerList"; + #endregion } diff --git a/HDL_ON/HDL_ON.projitems b/HDL_ON/HDL_ON.projitems index 00e53a2..7961367 100644 --- a/HDL_ON/HDL_ON.projitems +++ b/HDL_ON/HDL_ON.projitems @@ -60,31 +60,6 @@ <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\ArmSensor\SensorSmokePage.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\ArmSensor\SensorPirPage.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\ArmSensor\ArmSensorHistroyPaging.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\MusicMain.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31Radio.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\UpdateThread.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31RadioList.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MusicModel.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MusicSourcePage.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31PlayMusicPage.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LoveRadioList.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LoveList.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31USBMusicList.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31PlayStatus.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MyList.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\SendMethod.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LocalMusicList.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LoveMusicList.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MyListMusic.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\DialogView.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\TopView.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MusicView.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\PlayView.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\SizeClass.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\TipView.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MusicSourceView.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\SongView.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MyListView.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Electrical\TuyaFanPage.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Electrical\ClothesHangerPage.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Electrical\FanPage.cs" /> @@ -491,6 +466,26 @@ <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Electrical\SocketPage_InstantaneousValue.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Electrical\SocketPage_CumulativePowerConsumption.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\CancelAccountPage.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\MusicMain.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MusicModel.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MusicSourcePage.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31PlayMusicPage.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MyList.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\SendMethod.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31LoveMusicList.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MyListMusic.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\DialogView.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\TopView.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MusicView.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\PlayView.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\SizeClass.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\TipView.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MusicSourceView.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\SongView.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\View\MyListView.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31MusicFileList.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\A31SongPlay.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Music\MusicProperty.cs" /> </ItemGroup> <ItemGroup> <Folder Include="$(MSBuildThisFileDirectory)Entity\Device\" /> diff --git a/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs b/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs index 4507e35..5e0a123 100644 --- a/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs +++ b/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs @@ -125,7 +125,7 @@ break; case SPK.MusicStandard: case SPK.AvMusic: - Music.A31MusicModel.Current = (function as Music.A31MusicModel);//褰撳墠鎾斁鍣� + Music.A31MusicModel.Current.functionMusic =function;//褰撳墠鎾斁鍣� var a31PlayMusicPage = new Music.A31PlayMusicPage(); MainPage.BasePageView.AddChidren(a31PlayMusicPage); a31PlayMusicPage.Show(); diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs index 9443a70..3c652a7 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs @@ -856,29 +856,29 @@ if (SPK.MusicSpkList().Contains( function.spk)) { //var music = function as Music.A31MusicModel; - var music = Music.A31MusicModel.A31MusicModelList.Find((obj) => obj.sid == function.sid); - if (music == null) - { - continue; - } - if (music.ServerClientType == -1) - { - continue; - } - else if (music.ServerClientType == 1) - { - if (!music.MainPlayCollection) - { - continue; - } - } - else - { - if (!music.collect) - { - continue; - } - } + //var music = Music.A31MusicModel.A31MusicModelList.Find((obj) => obj.sid == function.sid); + //if (music == null) + //{ + // continue; + //} + //if (music.ServerClientType == -1) + //{ + // continue; + //} + //else if (music.ServerClientType == 1) + //{ + // if (!music.MainPlayCollection) + // { + // continue; + // } + //} + //else + //{ + // if (!music.collect) + // { + // continue; + // } + //} } else { @@ -1197,8 +1197,8 @@ SelectedImagePath = "FunctionIcon/Music/MusicPlayOnIcon.png", }; view.AddChidren(btnPower); - var a31player = (function as UI.Music.A31MusicModel); - btnState.Text = a31player.A31PlayStatus.Title; + + btnState.Text = function.GetAttrState("song_name"); btnState.SelectedTextColor = CSS_Color.MainBackgroundColor; btnState.TextColor = CSS_Color.MainBackgroundColor;//PromptingColor1 @@ -1207,21 +1207,22 @@ btnPower.MouseUpEventHandler = (sender, e) => { + + string status = "off"; if (btnPower.IsSelected) { btnPower.IsSelected = false; - Music.SendMethod.Pause(a31player); - a31player.A31PlayStatus.status = "pause"; - a31player.trait_on_off.curValue = "off"; + status = "off"; } else { btnPower.IsSelected = true; - Music.SendMethod.Play(a31player); - a31player.A31PlayStatus.status = "play"; - a31player.trait_on_off.curValue = "on"; + status = "on"; } - UpdataFunctionStates(a31player); + function.SetAttrState("on_off", status); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("on_off", status); + Music.SendMethod.mMethod.SendControlCommand(function, dic); }; } @@ -1279,14 +1280,14 @@ //鍙栨秷鏀惰棌浜嬩欢 Action cannelCollect = () => { function.collect = false; - if (SPK.MusicSpkList().Contains(function.spk))//澶勭悊闊充箰涓讳粠鍏崇郴 - { - if ((function as Music.A31MusicModel).ServerClientType == 1) - { - (function as Music.A31MusicModel).MainPlayCollection = false; - Music.A31MusicModel.Save(); - } - } + //if (SPK.MusicSpkList().Contains(function.spk))//澶勭悊闊充箰涓讳粠鍏崇郴 + //{ + // if ((function as Music.A31MusicModel).ServerClientType == 1) + // { + // (function as Music.A31MusicModel).MainPlayCollection = false; + // Music.A31MusicModel.Save(); + // } + //} string msg = function.name + Language.StringByID(StringId.CollectionCancelled); LoadDeviceFunctionControlZone(); function.CollectFunction(); diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs index 80793fd..f5198f6 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs @@ -244,11 +244,11 @@ function.collect = false; if (SPK.MusicSpkList().Contains(function.spk))//澶勭悊闊充箰涓讳粠鍏崇郴 { - if ((function as Music.A31MusicModel).ServerClientType == 1) - { - (function as Music.A31MusicModel).MainPlayCollection = false; - Music.A31MusicModel.Save(); - } + //if ((function as Music.A31MusicModel).ServerClientType == 1) + //{ + // (function as Music.A31MusicModel).MainPlayCollection = false; + // Music.A31MusicModel.Save(); + //} } string msg = function.name + Language.StringByID(StringId.CollectionCancelled); LoadDeviceFunctionControlZone(); @@ -374,7 +374,7 @@ { if (SPK.MusicSpkList().Contains(function.spk)) { - btn.Text = (function as Music.A31MusicModel).A31PlayStatus.Title; + btn.Text =function.GetAttrState("song_name"); } else { diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs b/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs index 5a6a5d3..09b860a 100644 --- a/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs @@ -156,12 +156,12 @@ else if (SPK.MusicSpkList().Contains(updataFunction.spk)) { #region 闊充箰鏇存柊 - var uMusic = updataFunction as Music.A31MusicModel; + var uMusic = updataFunction; if (cTag == updataFunction.spk + "_State_" + updataFunction.sid) { try { - (fcView.GetChildren(j) as Button).IsSelected = uMusic.A31PlayStatus.status == "play"; + (fcView.GetChildren(j) as Button).IsSelected = uMusic.GetAttrState("on_off") == "on"; } catch (Exception ex) { diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs b/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs index 0e8f778..ede9b51 100644 --- a/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs @@ -214,9 +214,12 @@ foreach (var m in Music.A31MusicModel.A31MusicModelList) { - if (m.roomIds.Contains(room.roomId)) + if (m.functionMusic.roomIds.Contains(room.roomId)) { - Music.SendMethod.Pause(m); + m.functionMusic.SetAttrState("on_off", "off"); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("on_off", "off"); + Music.SendMethod.mMethod.SendControlCommand(m.functionMusic, dic); } } }) diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs b/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs index 9a7fe8d..86d9ff5 100644 --- a/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs +++ b/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs @@ -408,7 +408,7 @@ SelectedImagePath = "MusicIcon/nextSelected.png", }; bodyDiv.AddChidren(btnNext); - LoadEvent_ControlMusic(btnPlay, btnNext, btnPrev, function as A31MusicModel); + LoadEvent_ControlMusic(btnPlay, btnNext, btnPrev, function); #endregion } diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs b/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs index cdaef53..3b8ac47 100644 --- a/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs @@ -291,7 +291,7 @@ /// <param name="btnOpen"></param> /// <param name="btnClose"></param> /// <param name="curtain"></param> - void LoadEvent_ControlMusic(Button btnPlay,Button btnNext,Button btnPrev, A31MusicModel a31player) + void LoadEvent_ControlMusic(Button btnPlay,Button btnNext,Button btnPrev, Function a31player) { if (a31player == null) return; @@ -299,7 +299,10 @@ btnPrev.MouseDownEventHandler = (sender, e) => { btnPrev.IsSelected = true; - SendMethod.Previous(a31player); + a31player.SetAttrState("song_step", "up"); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("song_step", "up"); + SendMethod.mMethod.SendControlCommand(a31player, dic); }; btnPrev.MouseUpEventHandler = (sender, e) => { @@ -308,24 +311,30 @@ ///鏆傚仠/鎾斁鐐瑰嚮浜嬩欢 btnPlay.MouseDownEventHandler = (sender, e) => { + string status = "off"; if (btnPlay.IsSelected) { btnPlay.IsSelected = false; - SendMethod.Pause(a31player); - a31player.A31PlayStatus.status = "pause"; + status = "off"; } else { btnPlay.IsSelected = true; - SendMethod.Play(a31player); - a31player.A31PlayStatus.status = "play"; + status = "on"; } + a31player.SetAttrState("on_off", status); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("on_off", status); + SendMethod.mMethod.SendControlCommand(a31player, dic); }; ///涓嬩竴鏇茬偣鍑讳簨浠� btnNext.MouseDownEventHandler = (sender, e) => { btnNext.IsSelected = true; - SendMethod.Next(a31player); + a31player.SetAttrState("song_step", "down"); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("song_step", "down"); + SendMethod.mMethod.SendControlCommand(a31player, dic); }; btnNext.MouseUpEventHandler = (sender, e) => { diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs index 7398574..d209740 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs @@ -682,7 +682,7 @@ case "time": { list = new List<string> { - "30 s", + //"30 s", "1 min", "2 min", "3 min", diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31LocalMusicList.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31LocalMusicList.cs deleted file mode 100644 index 89c9543..0000000 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31LocalMusicList.cs +++ /dev/null @@ -1,60 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Text; -using Shared; -namespace HDL_ON.UI.Music -{ - public class A31LocalMusicList : FrameLayout - { - public A31LocalMusicList() - { - Tag = "Music"; - } - VerticalRefreshLayout middViewLayout; - /// <summary> - /// 鍏堝姞杞界晫闈㈠嚭鏉� - /// </summary> - public void Show() - { - #region 鐣岄潰甯冨眬------ - this.BackgroundColor = MusicColor.ViewColor; - var topView = new TopView(); - this.AddChidren(topView.TopFLayoutView()); - topView.topNameBtn.TextID = StringId.localMusic; - topView.clickBackBtn.MouseUpEventHandler += (sender, e) => - { - this.RemoveFromParent(); - }; - middViewLayout = new VerticalRefreshLayout - { - BackgroundColor = MusicColor.WhiteColor, - Y = topView.fLayout.Bottom, - Height = Application.GetRealHeight(H_W.H - H_W.T_Height), - }; - this.AddChidren(middViewLayout); - middViewLayout.BeginHeaderRefreshingAction += () => - { - MusicView(); - middViewLayout.EndHeaderRefreshing(); - }; - #endregion - MusicView(); - } - /// <summary> - /// 鍔犺浇鏁版嵁鐨勬柟娉� - /// </summary> - public void MusicView() - { - middViewLayout.RemoveAll(); - UI2.FuntionControlView.Music.UpdateThread.playMusuc(middViewLayout, "鏈湴闊充箰", Language.StringByID(StringId.localMusic), MusicInfo.MusicInfoList, A31MusicModel.Current); - } - /// <summary> - /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 - /// </summary> - public void UpdateSelectedMusic() - { - UI2.FuntionControlView.Music.UpdateThread.updateThread(this, middViewLayout,A31MusicModel.Current); - } - - } -} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveList.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveList.cs deleted file mode 100644 index 17e903c..0000000 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveList.cs +++ /dev/null @@ -1,410 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Text; -using Shared; -namespace HDL_ON.UI.Music -{ - public class A31LoveList : FrameLayout - { - public A31LoveList() - { - Tag = "Music"; - } - - VerticalScrolViewLayout middViewLayout; - public void Show() - { - #region 鐣岄潰甯冨眬------ - this.BackgroundColor = MusicColor.ViewColor; - var topView = new TopView(); - this.AddChidren(topView.TopFLayoutView()); - topView.topNameBtn.TextID = StringId.myLove; - topView.clickBackBtn.MouseUpEventHandler += (sender, e) => - { - - if (updateSelectedMusicThread != null) - { - try - { - if (updateSelectedMusicThread.IsAlive) - { - updateSelectedMusicThread.Abort(); - ///鍏抽棴绾跨▼ - } - } - catch { } - } - this.RemoveFromParent(); - }; - - - middViewLayout = new VerticalScrolViewLayout - { - BackgroundColor = MusicColor.WhiteColor, - Y = topView.fLayout.Bottom, - Height = Application.GetRealHeight(H_W.H - H_W.T_Height), - }; - this.AddChidren(middViewLayout); - FileView(); - #endregion - } - /// <summary> - /// 鍔犺浇鏂囦欢澶筕iew鐨勬柟娉� - /// </summary> - void FileView() - { - for (int i = 0; i < 2; i++) - { - RowLayout addFlieRow = new RowLayout - { - Height = Application.GetRealHeight(104), - LineColor = MusicColor.WhiteColor, - SubViewWidth = Application.GetRealWidth(90),//鏀瑰彉缂栬緫鎺т欢瀹藉害澶氬皯锛� - }; - middViewLayout.AddChidren(addFlieRow); - //鏂囦欢鍥炬爣 - Button fileIconBtn = new Button - { - X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(8), - Width = Application.GetRealWidth(88), - Height = Application.GetRealWidth(88), - - }; - addFlieRow.AddChidren(fileIconBtn); - //鎾斁/鏆傚仠鍥炬爣 - Button playIconBtn = new Button - { - X = Application.GetRealWidth(78), - Y = Application.GetRealHeight(70), - Width = Application.GetRealWidth(24), - Height = Application.GetRealWidth(24), - UnSelectedImagePath = "MusicIcon/filePause.png", - SelectedImagePath = "MusicIcon/filePlay.png", - }; - addFlieRow.AddChidren(playIconBtn); - - - //鏂囦欢鍚嶆帶浠� - Button fileNameBtn = new Button - { - X = fileIconBtn.Right + Application.GetRealWidth(16), - Y = Application.GetRealHeight(42), - Width = Application.GetRealWidth(217), - Height = Application.GetRealHeight(20), - TextColor = MusicColor.TextColor, - TextSize = TextSize.Text14, - TextAlignment = TextAlignment.CenterLeft, - }; - addFlieRow.AddChidren(fileNameBtn); - if (i == 0) - { - fileIconBtn.UnSelectedImagePath = "MusicIcon/loveMusic.png"; - fileNameBtn.TextID = StringId.a31Music; - playIconBtn.Tag = Language.StringByID(StringId.a31Music);//璁板綍鍒楄〃鍚� - } - else - { - fileIconBtn.UnSelectedImagePath = "MusicIcon/loveRadio.png"; - fileNameBtn.TextID = StringId.radioLove; - playIconBtn.Tag = Language.StringByID(StringId.radioLove);//璁板綍鍒楄〃鍚� - } - //鐐瑰嚮鎸夐挳闅忔満鎾斁闊充箰 - playIconBtn.MouseUpEventHandler += (sender, e) => - { - //鐐瑰嚮鎸夐挳闅忔満鎾斁闊充箰 - if (fileNameBtn.Text == Language.StringByID(StringId.a31Music)) - { - ///鍠滅埍闊充箰鍒楄〃 - SelectedPaly(fileNameBtn.Text, A31MusicModel.Current.LoveMusicInfoList, playIconBtn); - } - else - { - ///鍠滅埍鐢靛彴鍒楄〃 - SelectedPaly(fileNameBtn.Text, A31MusicModel.Current.LoveRadioInfoList, playIconBtn); - } - - }; - Button clickBtn = new Button - { - X = fileIconBtn.Right + Application.GetRealWidth(16), - Width = Application.GetRealWidth(375 - 138), - Height = Application.GetRealHeight(104), - }; - addFlieRow.AddChidren(clickBtn); - clickBtn.MouseUpEventHandler += (sender, e) => - { - if (fileNameBtn.Text == Language.StringByID(StringId.a31Music)) - { - ///鍠滅埍闊充箰鍒楄〃 - A31LoveMusicList a31LoveMusicList = new A31LoveMusicList(); - MainPage.BasePageView.AddChidren(a31LoveMusicList); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - a31LoveMusicList.Show(); - a31LoveMusicList.UpdateSelectedMusic(); - } - else - { - ///鍠滅埍鐢靛彴鍒楄〃 - A31LoveRadioList a31LoveRadioList = new A31LoveRadioList(); - MainPage.BasePageView.AddChidren(a31LoveRadioList); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - a31LoveRadioList.Show(); - a31LoveRadioList.UpdateSelectedMusic(); - } - - }; - - } - } - /// <summary> - /// 鏆傚仠/鎾斁鍥炬爣鐐瑰嚮鎾斁 - /// </summary> - /// <param name="listName"></param> - /// <param name="listMusic"></param> - /// <param name="playIconBtn"></param> - void SelectedPaly(string listName, List<MusicInfo> listMusic, Button playIconBtn) - { - - ///鏌ユ壘褰撳墠鎾斁闊充箰鏄惁杩欎釜鍒楄〃 - if (playIconBtn.IsSelected) - { - if (listName == A31MusicModel.Current.A31PlayStatus.Artist && A31MusicModel.Current.A31PlayStatus.status == "play") - { - - SendMethod.Pause(A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.status = "pause"; - } - - } - else - { - if (listMusic.Count == 0) - { - return; - } - if (listName == A31MusicModel.Current.A31PlayStatus.Artist && A31MusicModel.Current.A31PlayStatus.status != "play") - { - SendMethod.Play(A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.status = "play"; - } - else - { - ///鍙栭殢鏈烘暟; - var ra = new Random { }.Next(0, listMusic.Count); - ///鏌ユ壘褰撳墠鐨勯煶涔�; - var songs = listMusic[ra]; - //鐐瑰嚮鎸夐挳闅忔満鎾斁闊充箰 - System.Threading.Tasks.Task.Run(() => - { - System.Threading.Thread.Sleep(50); - Application.RunOnMainThread(() => - { - //绉婚櫎鐣岄潰 - System.Threading.Tasks.Task.Run(() => - { - PushList(songs, listName, listMusic); - }); - }); - }); - } - - } - } - System.Threading.Thread updateSelectedMusicThread; - /// <summary> - /// 瀹氭椂鏇存柊鏂囦欢澶规挱鏀剧姸鎬� - /// </summary> - public void UpdateSelectedFile() - { - updateSelectedMusicThread = new System.Threading.Thread(() => - { - while (this.Parent != null) - { - System.Threading.Thread.Sleep(1000); - Application.RunOnMainThread(() => - { - try - { - for (int i = 0; i < middViewLayout.ChildrenCount; i++) - { - RowLayout view = (RowLayout)middViewLayout.GetChildren(i); - var playBtn = (Button)view.GetChildren(1);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button - ///鏌ユ壘褰撳墠鎾斁闊充箰鏄惁杩欎釜鍒楄〃 - if (A31MusicModel.Current.A31PlayStatus.Artist == playBtn.Tag.ToString() && A31MusicModel.Current.A31PlayStatus.status == "play") - { - playBtn.IsSelected = true; - } - else - { - playBtn.IsSelected = false; - } - } - } - catch { } - - }); - } - }) - { IsBackground = true }; - updateSelectedMusicThread.Start(); - } - /// <summary> - /// 鎺ㄩ�佹挱鏀惧懡浠� - /// </summary> - /// <param name="musicInfo">鎾斁闊充箰</param> - /// <param name="listName">鍒楄〃鍚嶇О</param> - /// <param name="musicList">鎺ㄩ�佸垪琛�(榛樿鎺�50棣�)</param> - public void PushList(MusicInfo musicInfo, string listName, List<MusicInfo> musicList) - { - - //鏈�澶у彂閫佺殑鏉℃暟 - int maxCount = 50; - //鎵惧嚭褰撳墠鐐瑰嚮闊充箰鐨勭储寮� - int statIndex = musicList.FindIndex((obj) => { return obj == musicInfo; }); - //鐐瑰嚮鍚庨潰杩樻湁澶氬皯鏉¢煶涔� - int count = musicList.Count - statIndex; - int endIndex = 0; - if (maxCount < count) - { - //濡傛灉鍚庨潰鐨勯煶涔愬ぇ浜庢渶澶ф暟锛岃缃悗闈㈡暟鎹殑鏈�澶х储寮� - endIndex = statIndex + maxCount - 1; - } - else - { - //濡傛灉鍚庨潰鏁版嵁涓嶅锛屽氨鐢ㄦ�绘暟鍑忓幓鏈�澶ф潯鏁帮紝寰楀埌寮�濮嬬储寮� - statIndex = musicList.Count - maxCount - 1; - endIndex = musicList.Count - 1; - } - //濡傛灉寮�濮嬬储寮曞皬浜�0锛岄偅灏辫缃负绗竴鏉¢煶涔� - if (statIndex < 0) - { - statIndex = 0; - } - - StringBuilder sb = new StringBuilder(); - sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); - sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - sb.AppendLine("<s:Body>"); - sb.AppendLine("<u:CreateQueue xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">"); - sb.AppendLine("<QueueContext><?xml version=\"1.0\"?>"); - sb.AppendLine("<PlayList>"); - sb.AppendLine("<ListName>DLNA" + listName + "</ListName>"); - sb.AppendLine("<ListInfo>"); - sb.AppendLine("<Radio>0</Radio>");// - sb.AppendLine("<SourceName>UPnPServer</SourceName>");// - sb.AppendLine("<MarkSearch>0</MarkSearch>"); - sb.AppendLine("<TrackNumber>" + (endIndex - statIndex + 1) + "</TrackNumber>"); - sb.AppendLine("<Quality>0</Quality>"); - sb.AppendLine("<UpdateTime>5367</UpdateTime>"); - sb.AppendLine("<LastPlayIndex>2</LastPlayIndex>"); - sb.AppendLine("<SwitchPageMode>0</SwitchPageMode>"); - sb.AppendLine("<CurrentPage>0</CurrentPage>"); - sb.AppendLine("<TotalPages>0</TotalPages>"); - sb.AppendLine("</ListInfo>"); - sb.AppendLine("<Tracks>"); - - int number = 1; - - for (int i = statIndex, Tracknumber = 1; i <= endIndex; i++, Tracknumber++) - { - var tempMusicInfo = musicList[i]; - - if (musicInfo == tempMusicInfo) - { - number = Tracknumber; - } - - if (tempMusicInfo.SourceType == "Local") - { - tempMusicInfo.URL = "http://" + new Shared.Net.NetWiFi().IpAddress + ":" + com.hdl.on.Server.Port + "/" + tempMusicInfo.ID; - } - - - sb.AppendLine("<Track" + Tracknumber + ">"); - sb.AppendLine("<URL>" + tempMusicInfo.URL + "</URL>"); - sb.AppendLine("<Metadata>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;"); - sb.AppendLine("&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:song=&quot;www.wiimu.com/song/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;"); - sb.AppendLine("&lt;upnp:class&gt;object.item.audioItem.musicTrack&lt;/upnp:class&gt;"); - sb.AppendLine("&lt;item id=&quot;0&quot;&gt;"); - sb.AppendLine("&lt;song:subid&gt;&lt;/song:subid&gt;"); - sb.AppendLine("&lt;song:description&gt;unknown&lt;/song:description&gt;"); - sb.AppendLine("&lt;song:skiplimit&gt;6&lt;/song:skiplimit&gt;"); - sb.AppendLine("&lt;song:id&gt;" + tempMusicInfo.ID + "&lt;/song:id&gt;"); - sb.AppendLine("&lt;song:like&gt;0&lt;/song:like&gt;"); - sb.AppendLine("&lt;song:singerid&gt;0&lt;/song:singerid&gt;"); - sb.AppendLine("&lt;song:albumid&gt;" + tempMusicInfo.AlbumId + "&lt;/song:albumid&gt;"); - - sb.AppendLine("&lt;res protocolInfo=&quot;http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;&quot; duration=&quot;" + "0:0:0.0" + "&quot;&gt;" + tempMusicInfo.URL + "&lt;/res&gt;"); - - sb.AppendLine("&lt;dc:title&gt;" + tempMusicInfo.Title + "&lt;/dc:title&gt;"); - sb.AppendLine("&lt;dc:creator&gt;DJ Sanny J&lt;/dc:creator&gt;"); - sb.AppendLine("&lt;upnp:artist&gt;" + listName + "&lt;/upnp:artist&gt;"); - sb.AppendLine("&lt;upnp:album&gt;" + tempMusicInfo.Album + "&lt;/upnp:album&gt;"); - sb.AppendLine("&lt;upnp:albumArtURI&gt;unknown&lt;/upnp:albumArtURI&gt;"); - sb.AppendLine("&lt;/item&gt;"); - sb.AppendLine("&lt;/DIDL-Lite&gt;"); - sb.AppendLine("</Metadata>"); - sb.AppendLine("<Id>" + tempMusicInfo.ID + "</Id>"); - sb.AppendLine("<Source>STATION-NETWORK</Source>");//UPnPServer - sb.AppendLine("<Key>" + tempMusicInfo.URL + "</Key>"); - sb.AppendLine("</Track" + Tracknumber + ">"); - } - sb.AppendLine("</Tracks>"); - sb.AppendLine("</PlayList>"); - sb.AppendLine("</QueueContext>"); - sb.AppendLine("</u:CreateQueue>"); - sb.AppendLine("</s:Body>"); - sb.AppendLine("</s:Envelope>"); - - SendMusicLists(A31MusicModel.Current.IPAddress, A31MusicModel.Current.Port, "CreateQueue", sb.ToString()); - - StringBuilder playString = new StringBuilder(); - playString.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); - playString.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - playString.AppendLine("<s:Body>"); - playString.AppendLine("<u:PlayQueueWithIndex xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">"); - playString.AppendLine("<QueueName>DLNA" + listName + "</QueueName>"); - playString.AppendLine("<Index>" + number + "</Index>"); - playString.AppendLine("</u:PlayQueueWithIndex>"); - playString.AppendLine("</s:Body>"); - playString.AppendLine("</s:Envelope>"); - - Play(A31MusicModel.Current.IPAddress, A31MusicModel.Current.Port, playString.ToString()); - } - - void SendMusicLists(string ip, int port, string soapAction, string listInfo) - { - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#" + soapAction + "\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - byte[] recevieBytes = webClient.UploadData(new Uri("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(listInfo)); - var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); - } - catch - { - - } - } - - void Play(string ip, int port, string info) - { - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#PlayQueueWithIndex\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - byte[] recevieBytes = webClient.UploadData(new Uri("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(info)); - var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); - } - catch - { - - } - } - - - } -} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveMusicList.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveMusicList.cs index e0a95e1..751d459 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveMusicList.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveMusicList.cs @@ -49,14 +49,14 @@ public void MusicView(string listName) { middViewLayout.RemoveAll(); - UI2.FuntionControlView.Music.UpdateThread.playMusuc(middViewLayout, "鎴戠殑鏈�鐖�", listName, A31MusicModel.Current.LoveMusicInfoList, A31MusicModel.Current); + //UpdateThread.PlayMusicClick(middViewLayout, "鎴戠殑鏈�鐖�", listName, A31MusicModel.Current.LoveMusicInfoList); } /// <summary> /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 /// </summary> public void UpdateSelectedMusic() { - UI2.FuntionControlView.Music.UpdateThread.updateThread(this, middViewLayout,A31MusicModel.Current); + UpdateThread.updateCurrMusicThread(this, middViewLayout,A31MusicModel.Current); } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveRadioList.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveRadioList.cs deleted file mode 100644 index 4369486..0000000 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveRadioList.cs +++ /dev/null @@ -1,309 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Net; -using System.Text; -using Shared; -namespace HDL_ON.UI.Music -{ - public class A31LoveRadioList : FrameLayout - { - public A31LoveRadioList() - { - Tag = "Music"; - } - - VerticalRefreshLayout middViewLayout; - /// <summary> - /// 鍏堝姞杞界晫闈㈠嚭鏉� - /// </summary> - public void Show() - { - #region 鐣岄潰甯冨眬------ - - this.BackgroundColor = MusicColor.ViewColor; - var topView = new TopView(); - this.AddChidren(topView.TopFLayoutView()); - topView.topNameBtn.TextID = StringId.radioLove; - topView.clickBackBtn.MouseUpEventHandler += (sender, e) => - { - - if (updateSelectedMusicThread != null) - { - try - { - if (updateSelectedMusicThread.IsAlive) - { - updateSelectedMusicThread.Abort(); - ///鍏抽棴绾跨▼ - } - } - catch { } - } - this.RemoveFromParent(); - }; - middViewLayout = new VerticalRefreshLayout - { - BackgroundColor = MusicColor.WhiteColor, - Y = topView.fLayout.Bottom, - Height = Application.GetRealHeight(H_W.H - H_W.T_Height), - }; - this.AddChidren(middViewLayout); - middViewLayout.BeginHeaderRefreshingAction += () => - { - middViewLayout.EndHeaderRefreshing(); - }; - #endregion - MusicView(Language.StringByID(StringId.radioLove)); - } - /// <summary> - /// 鍔犺浇鏁版嵁鐨勬柟娉� - /// </summary> - public void MusicView(string listName) - { - middViewLayout.RemoveAll(); - for (int i = 0; i < A31MusicModel.Current.LoveRadioInfoList.Count; i++) - { - var radioInfo = A31MusicModel.Current.LoveRadioInfoList[i]; - if (string.IsNullOrEmpty(radioInfo.Title)) - { - //闃叉姝屾洸鍚嶅瓧涓虹┖鎶涘紓甯� - radioInfo.Title = " "; - } - FrameLayout radioViewFl = new FrameLayout - { - Width = Application.GetRealWidth(375), - Height = Application.GetRealHeight(67), - }; - middViewLayout.AddChidren(radioViewFl); - //榛樿鐢靛彴鍥炬爣 - Button radioIconBtn = new Button - { - X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(18), - Width = Application.GetRealWidth(32), - Height = Application.GetRealWidth(32), - UnSelectedImagePath = "MusicIcon/radioIcon.png", - }; - radioViewFl.AddChidren(radioIconBtn); - //鐢靛彴鍚嶇О - Button radioNameBtn = new Button - { - X = Application.GetRealWidth(60), - Y = Application.GetRealHeight(23), - Width = Application.GetRealWidth(250), - Height = Application.GetRealHeight(22), - TextColor = MusicColor.MusicTxet14Color, - TextSize = TextSize.Text16, - TextAlignment = TextAlignment.CenterLeft, - Tag = radioInfo.URL, - Text = radioInfo.Title.Trim() - }; - radioViewFl.AddChidren(radioNameBtn); - //娣诲姞鍠滅埍鐢靛彴 - Button loveIcon = new Button - { - X = Application.GetRealWidth(335), - Y = Application.GetRealHeight(20), - Width = Application.GetRealWidth(28), - Height = Application.GetRealWidth(28), - UnSelectedImagePath = "MusicIcon/loveSelected.png", - }; - radioViewFl.AddChidren(loveIcon); - loveIcon.MouseUpEventHandler += (sender, e) => - { - var radioselected = A31MusicModel.Current.LoveRadioInfoList.Find((m) => m.URL == radioInfo.URL); - if (radioselected != null) - { - ///瀛樺湪灏卞垹闄� - A31MusicModel.Current.LoveRadioInfoList.Remove(radioInfo); - } - A31MusicModel.Save(); - radioViewFl.RemoveFromParent(); - }; - - //鐐瑰嚮鎺т欢 - Button clickBtn = new Button - { - Width = Application.GetRealWidth(280), - Height = Application.GetRealHeight(44), - Tag = radioInfo,//鏍囪鎾斁鍝竴棣栨瓕鏇� - }; - radioViewFl.AddChidren(clickBtn); - ///鐐瑰嚮鎾斁浜嬩欢 - clickBtn.MouseUpEventHandler += (sender, e) => - { - - System.Threading.Tasks.Task.Run(() => - { - System.Threading.Thread.Sleep(50); - Application.RunOnMainThread(() => - { - //绉婚櫎鐣岄潰 - A31MusicModel.Current.A31PlayStatus.Title = radioNameBtn.Text; - MainPage.BasePageView.RemoveViewByTag("Music"); - System.Threading.Tasks.Task.Run(() => - { - CnpushList(clickBtn.Tag as MusicInfo, listName); - }); - }); - }); - - }; - - } - } - /// <summary> - /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 - /// </summary> - System.Threading.Thread updateSelectedMusicThread; - public void UpdateSelectedMusic() - { - updateSelectedMusicThread = new System.Threading.Thread(() => - { - while (this.Parent != null) - { - System.Threading.Thread.Sleep(1000); - Application.RunOnMainThread(() => - { - try - { - for (int i = 0; i < middViewLayout.ChildrenCount; i++) - { - FrameLayout view = (FrameLayout)middViewLayout.GetChildren(i); - var songNameBtn = (Button)view.GetChildren(1);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button - if (A31MusicModel.Current.A31PlayStatus.Title == songNameBtn.Text.ToString()) - { - songNameBtn.TextColor = MusicColor.SelectedColor; - } - else - { - songNameBtn.TextColor = MusicColor.MusicTxet14Color; - } - - - } - } - catch { } - - }); - } - }); - updateSelectedMusicThread.Start(); - } - - /// <summary> - ///鏀惰棌鍒楄〃鐢靛彴鎾斁 - /// </summary> - /// <param name="listName"></param> - public void CnpushList(MusicInfo musicInfo, string listName) - { - - StringBuilder sb = new StringBuilder(); - sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>"); - sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - sb.AppendLine("<s:Body>"); - sb.AppendLine("<u:CreateQueue xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">"); - sb.AppendLine("<QueueContext>"); - sb.AppendLine("<?xml version="1.0" ?>"); - sb.AppendLine("<PlayList>"); - sb.AppendLine("<ListName>" + listName + "</ListName>"); - sb.AppendLine("<ListInfo>"); - sb.AppendLine("<Radio>1</Radio>"); - sb.AppendLine("<SourceName>TuneIn</SourceName>"); - sb.AppendLine("<TrackNumber>1</TrackNumber>"); - sb.AppendLine("<SearchUrl>http://opml.radiotime.com/Tune.ashx?id=s112201&amp;partnerId=yvcOjvJP</SearchUrl>"); - sb.AppendLine("<Quality>3</Quality>"); - sb.AppendLine("<RealIndex>0</RealIndex>"); - sb.AppendLine("<SrcParent></SrcParent>"); - sb.AppendLine("<PicUrl></PicUrl>"); - sb.AppendLine("</ListInfo>"); - sb.AppendLine("<Tracks>"); - - var url = musicInfo.URL; - - if (url != null) - { - url = url.TrimEnd('\n').Replace("&", "&amp;"); - } - else - { - return; - } - sb.AppendLine("<Track" + 1 + ">"); - sb.AppendLine("<Source>TuneIn</Source>"); - sb.AppendLine("<URL>" + url + "</URL>"); - sb.AppendLine("<Source>TuneIn</Source>"); - sb.AppendLine("<Id>0</Id>"); - sb.AppendLine("<Key>http://so.ard.iyyin.com/s/song_with_out?q=%E8%8A%B1%E9%83%BD%E7%94%B5%E5%8F%B0+100.5+%28%E6%B5%81%E8%A1%8C%E9%9F%B3%E4%B9%90%E5%89%8D40%29%20TuneIn&amp;size=50&amp;page=1</Key>"); - sb.AppendLine("<Metadata>"); - sb.AppendLine("&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:song=&quot;www.wiimu.com/song/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;"); - sb.AppendLine("&lt;upnp:class&gt;object.item.audioItem.musicTrack&lt;/upnp:class&gt;"); - sb.AppendLine("&lt;item&gt;"); - sb.AppendLine("&lt;song:bitrate&gt;0&lt;/song:bitrate&gt;"); - sb.AppendLine("&lt;song:id&gt;0&lt;/song:id&gt;"); - sb.AppendLine("&lt;song:singerid&gt;0&lt;/song:singerid&gt;"); - sb.AppendLine("&lt;song:albumid&gt;0&lt;/song:albumid&gt;"); - sb.AppendLine("&lt;res protocolInfo=&quot;http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;&quot; duration=&quot;1000&quot;&gt;" + url + "&lt;/res&gt;"); - sb.AppendLine("&lt;dc:title&gt;" + musicInfo.Title + "&lt;/dc:title&gt;"); - sb.AppendLine("&lt;upnp:artist&gt;TuneIn&lt;/upnp:artist&gt;"); - sb.AppendLine("&lt;upnp:album&gt;&lt;/upnp:album&gt;"); - sb.AppendLine("&lt;upnp:albumArtURI&gt;" + musicInfo.Image + "&lt;/upnp:albumArtURI&gt;"); - sb.AppendLine("&lt;/item&gt;"); - sb.AppendLine("&lt;/DIDL-Lite&gt;"); - sb.AppendLine("</Metadata>"); - sb.AppendLine("</Track" + 1 + ">"); - - sb.AppendLine("</Tracks>"); - sb.AppendLine("</PlayList>"); - sb.AppendLine("</QueueContext>"); - sb.AppendLine("</u:CreateQueue>"); - sb.AppendLine("</s:Body>"); - sb.AppendLine("</s:Envelope>"); - //sendMusicLists(a31.IPAddress, a31.Port, "CreateQueue", sb.ToString()); - sendMusicLists(A31MusicModel.Current.IPAddress, A31MusicModel.Current.Port, "CreateQueue", sb.ToString()); - - StringBuilder playString = new StringBuilder(); - playString.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>"); - playString.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - playString.AppendLine("<s:Body>"); - playString.AppendLine("<u:PlayQueueWithIndex xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">"); - playString.AppendLine("<QueueName>" + listName + "</QueueName>"); - playString.AppendLine("<Index>" + 1 + "</Index>"); - playString.AppendLine("</u:PlayQueueWithIndex>"); - playString.AppendLine("</s:Body>"); - playString.AppendLine("</s:Envelope>"); - - play(A31MusicModel.Current.IPAddress, A31MusicModel.Current.Port, playString.ToString()); - - } - - void sendMusicLists(string ip, int port, string soapAction, string listInfo) - { - WebClient webClient = new WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#" + soapAction + "\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - byte[] recevieBytes = webClient.UploadData(new Uri("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(listInfo)); - var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); - } - catch { } - } - - void play(string ip, int port, string info) - { - WebClient webClient = new WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#PlayQueueWithIndex\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - byte[] recevieBytes = webClient.UploadData(new Uri("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(info)); - var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); - } - catch - { - - } - } - } -} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicFileList.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicFileList.cs new file mode 100644 index 0000000..2982d04 --- /dev/null +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicFileList.cs @@ -0,0 +1,115 @@ +锘縰sing System; +using System.Collections.Generic; +using Shared; +namespace HDL_ON.UI.Music +{ + public class A31MusicFileList : FrameLayout + { + public A31MusicFileList() + { + Tag = "Music"; + } + VerticalRefreshLayout middViewLayout; + public void Show() + { + #region 鐣岄潰甯冨眬------ + + this.BackgroundColor = MusicColor.ViewColor; + var topView = new TopView(); + this.AddChidren(topView.TopFLayoutView()); + topView.topNameBtn.TextID = StringId.localMusic; + topView.clickBackBtn.MouseUpEventHandler += (sender, e) => + { + this.RemoveFromParent(); + }; + middViewLayout = new VerticalRefreshLayout + { + BackgroundColor = MusicColor.WhiteColor, + Y = topView.fLayout.Bottom, + Height = Application.GetRealHeight(H_W.H - H_W.T_Height), + }; + this.AddChidren(middViewLayout); + #endregion + + middViewLayout.BeginHeaderRefreshingAction += () => + { + System.Threading.Tasks.Task.Run(() => + { + try + { + SendMethod.mMethod.GetPalyList(A31MusicModel.Current.functionMusic); + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + this.FileView(); + middViewLayout.EndHeaderRefreshing(); + }); + } + }); + + }; + + } + /// <summary> + /// 鍔犺浇鏂囦欢澶筕iew鐨勬柟娉� + /// </summary> + public void FileView() + { + middViewLayout.RemoveAll(); + for (int i = 0; i < A31MusicModel.Current.palyLists.Count; i++) + { + var list = A31MusicModel.Current.palyLists[i]; + RowLayout addFlieRow = new RowLayout + { + Height = Application.GetRealHeight(104), + LineColor = MusicColor.WhiteColor, + SubViewWidth = Application.GetRealWidth(90),//鏀瑰彉缂栬緫鎺т欢瀹藉害澶氬皯锛� + }; + middViewLayout.AddChidren(addFlieRow); + //鏂囦欢鍥炬爣 + Button fileIconBtn = new Button + { + X = Application.GetRealWidth(16), + Y = Application.GetRealHeight(8), + Width = Application.GetRealWidth(88), + Height = Application.GetRealWidth(88), + UnSelectedImagePath = "MusicIcon/fileList.png", + }; + addFlieRow.AddChidren(fileIconBtn); + + //鏂囦欢鍚嶆帶浠� + Button fileNameBtn = new Button + { + X = fileIconBtn.Right + Application.GetRealWidth(16), + Y = Application.GetRealHeight(42), + Width = Application.GetRealWidth(217), + Height = Application.GetRealHeight(20), + TextColor = MusicColor.TextColor, + TextSize = TextSize.Text14, + TextAlignment = TextAlignment.CenterLeft, + Text = list.group, + }; + addFlieRow.AddChidren(fileNameBtn); + + Button clickBtn = new Button + { + X = fileIconBtn.Right + Application.GetRealWidth(16), + Width = Application.GetRealWidth(375 - 138), + Height = Application.GetRealHeight(104), + }; + addFlieRow.AddChidren(clickBtn); + clickBtn.MouseUpEventHandler += (sender, e) => + { + A31SongPlay a31Song = new A31SongPlay(); + MainPage.BasePageView.AddChidren(a31Song); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + a31Song.Show(list.songs, list.group); + }; + + } + } + } +} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs index 13991b2..92009db 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs @@ -7,88 +7,22 @@ { [System.Serializable] - public class A31MusicModel : Function + public class A31MusicModel { public static List<A31MusicModel> A31MusicModelList = new List<A31MusicModel> { }; static readonly string a31MusiceModeListFilePath = "A31MusiceModeListFilePath"; static A31MusicModel() { - Refresh(); + //Refresh(); } - static List<System.Threading.Thread> updataMusicStatesListThread = new List<System.Threading.Thread>(); + /// <summary> - /// 璇诲彇闊充箰鐘舵�� + /// 闊充箰鍔熻兘 /// </summary> - public static void ReadMusicStates() - { - RemoveListThread(); - if (GetCollection) - { - for (int i = 0; i < A31MusicModelList.Count; i++) - { - var a31player = A31MusicModelList[i]; - var musicThread = new System.Threading.Thread(() => - { - while (true) - { - System.Threading.Thread.Sleep(1000); - if (!a31player.IsOnLine) - { - continue; - } - SendMethod.ReadStatus(a31player); - } - }) - { IsBackground = true, Name = "A31" }; - musicThread.Start(); - updataMusicStatesListThread.Add(musicThread); - } - } - } - - /// <summary> - /// 绉婚櫎涔嬪墠鐨勭嚎绋� - /// </summary> - public static void RemoveListThread() { - for (int i = 0; i < updataMusicStatesListThread.Count;) - { - try - { - var thread = updataMusicStatesListThread[i]; - if (thread.IsAlive) - { - thread.Abort(); - } - updataMusicStatesListThread.Remove(thread); - } - catch (Exception e) - { - MainPage.Log("clearA31Threads error : " + e.Message); - } - finally - { - MainPage.Log("clearA31Threads over"); - } - } - } - /// <summary> - /// 闊充箰鍒楄〃閲屾槸鍚︽湁闊充箰琚敹钘忚繃 - /// </summary> - static bool GetCollection - { - get - { - for (int i = 0; i < A31MusicModelList.Count; i++) - { - if (A31MusicModelList[i].collect) - { - return true; //鏌ヨ鏄惁鏈夐煶涔愯鏀惰棌杩� - } - } - return false; - } - } + public Function functionMusic = new Function(); + + /// <summary> ///淇濆瓨褰撳墠闊充箰鍒楄〃 /// </summary> @@ -116,51 +50,27 @@ A31MusicModelList.RemoveAll((obj) => obj == null); } - /// <summary> - /// 闊充箰鎾斁鍣ㄥ悕绉� - /// </summary> - public string Name = string.Empty; + /// <summary> /// 涓婁竴娆℃洿鏂扮殑鏃堕棿 /// 璁板綍鏁版嵁鍙嶉鐨勬椂闂�(鍥犱负鏈夋椂闂寸綉缁滃樊鏁版嵁涓嶅洖澶嶏紝瀵艰嚧鍒锋柊褰撳墠鎾斁闊充箰鏃堕棿涓嶆纭�) /// ((褰撳墠鏃堕棿)DateTime.Now - (璁板綍鏃堕棿)LastDateTimeLastDateTime).TotalSeconds=璇樊鏃堕棿(绉�) /// </summary> public DateTime LastDateTime; - /// <summary> - /// IP鍦板潃 - /// </summary> - public string IPAddress = "192.168.1.100"; - - /// <summary> - /// 绔彛 - /// </summary> - public int Port = 49153; - - /// <summary> - /// 鏄惁鏄挱鏀惧櫒鍒楄〃鏈�鍚庝竴涓�(true) - /// </summary> - public bool IsEnd = false; - - public int A31DeviceType; - - //public string a31Source = "wifi"; - //public string a31Source = string.Empty; + /// <summary> /// 闊充箰鎾斁鍣↖D /// </summary> public string UniqueDeviceName = string.Empty; - /// <summary> - /// 褰撳墠鎾斁鐘舵�� - /// </summary> - public A31PlayStatus A31PlayStatus = new A31PlayStatus(); + public MusicInfo CurrentMusic = new MusicInfo(); /// <summary> ///褰撳墠鎾斁鐨勫垪琛ㄤ俊鎭� /// </summary> - public List<MusicInfo> CurrentPlayMusicInfoList = new List<MusicInfo>(); + public List<Songs> CurrentPlayMusicInfoList = new List<Songs>(); /// <summary> /// 鏄惁鍏佽鏄剧ず @@ -168,47 +78,15 @@ public bool IsCanShow = true; /// <summary> - /// 鏄惁鍦ㄧ嚎锛屽鏋滃湪绾垮氨鍏佽璇诲彇淇℃伅 + /// 鍒楄〃 /// </summary> - public bool IsOnLine = true; + public List<PalyList> palyLists = new List<PalyList>(); /// <summary> /// 鍠滅埍闊充箰鍒楄〃 /// </summary> - public List<MusicInfo> LoveMusicInfoList = new List<MusicInfo>(); + public List<Songs> LoveMusicInfoList = new List<Songs>(); - /// <summary> - /// DLNA鎵�鏈夊垪琛� - /// </summary> - public List<MusicInfo> dlnaMusicInfoLists = new List<MusicInfo>(); - - /// <summary> - /// 鐢靛彴鎵�鏈夊垪琛� - /// </summary> - public List<MusicInfo> CnRadioInfoList = new List<MusicInfo>(); - - /// <summary> - /// vTuner鐢靛彴鎵�鏈夊垪琛� - /// </summary> - public List<MusicInfo> vTunerList = new List<MusicInfo>(); - - /// <summary> - /// 鍠滅埍鐢靛彴鍒楄〃 - /// </summary> - public List<MusicInfo> LoveRadioInfoList = new List<MusicInfo>(); - - /// <summary> - /// Pandora鐢靛彴鎵�鏈夊垪琛� - /// </summary> - public List<MusicInfo> PanRadioInfoList = new List<MusicInfo>(); - /// <summary> - /// usb鍒楄〃 - /// </summary> - public List<MusicInfo> USBList = new List<MusicInfo>(); - /// <summary> - /// Tidal鍠滅埍鍒楄〃 - /// </summary> - public List<MusicInfo> TidalLikelist = new List<MusicInfo>(); /// <summary> ///鍒涘缓闊充箰鏂囦欢鍒楄〃 /// </summary> @@ -218,53 +96,22 @@ /// </summary> public static A31MusicModel Current; - public int _ServerClientType; - /// <summary> - /// -1琛ㄧず浠庣殑0琛ㄧず榛樿1琛ㄧず涓荤殑 - /// </summary> - public int ServerClientType - { - get - { - return _ServerClientType; - } - set - { - _ServerClientType = value; - if(value == 0) - { - name = Name; - } - } - } - /// <summary> - /// 璁板綍涓绘挱鏀惧櫒IP - /// </summary> - public string MainPlayIP = string.Empty; + + - public string _MainPlayName = string.Empty; /// <summary> - /// 璁板綍涓绘挱鏀惧櫒鍚嶇О + /// 鎸囧畾鍒楄〃鍚嶈幏鍙栭煶涔愬垪琛� /// </summary> - public string MainPlayName + /// <returns></returns> + public List<Songs> GetSongList(string listName) { - get - { - return _MainPlayName; + var list = palyLists.Find((o)=>o.group==listName); + if (list==null) { + return new List<Songs>(); } - set - { - _MainPlayName = value; - if(ServerClientType == 1) - { - name = value; - } - } + return list.songs; } - /// <summary> - /// 璁板綍涓绘挱鏀惧櫒鏄惁琚敹钘�(绉�妗″畾涔夌殑) - /// </summary> - public bool MainPlayCollection = false; + public Slaves Slave = new Slaves(); /// <summary> @@ -272,6 +119,11 @@ /// </summary> public static DateTime ProgressDateTime = DateTime.Now; + /// <summary> + /// 鍒ゆ柇鏄惁鏄痡son鏁版嵁 + /// </summary> + /// <param name="json"></param> + /// <returns></returns> public static bool IsJson(string json) { try @@ -310,7 +162,7 @@ /// <summary> /// 鍒楄〃姝屾洸淇℃伅 /// </summary> - public List<MusicInfo> MusicInfoList = new List<MusicInfo>(); + public List<Songs> MusicInfoList = new List<Songs>(); } [System.Serializable] public class TidalMusicInfo : MusicInfo @@ -340,4 +192,61 @@ public string uuid = string.Empty; } + [System.Serializable] + /// <summary> + /// 鏀寔澶氫釜闊充箰 + /// </summary> + public class PalyListInfo + { + /// <summary> + /// 闊充箰sid + /// </summary> + public string sid = string.Empty; + /// <summary> + /// 瑙i噴澶氫釜闊充箰 + /// </summary> + public List<PalyList> playlist = new List<PalyList>(); + } + + [System.Serializable] + /// <summary> + /// 鍒楄〃淇℃伅 + /// </summary> + public class PalyList + { + /// <summary> + /// 鍒楄〃鍚� + /// </summary> + public string group = string.Empty; + /// <summary> + /// 鍒楄〃姝屾洸淇℃伅 + /// </summary> + public List<Songs> songs = new List<Songs>(); + } + [System.Serializable] + public class Songs:MusicInfo + { + /// <summary> + /// 姝屾洸鍚嶇О + /// </summary> + public string name = string.Empty; + /// <summary> + /// 澶у皬 + /// </summary> + public string size = string.Empty; + /// <summary> + /// 鏃堕暱 + /// </summary> + public string time = string.Empty; + /// <summary> + /// 绫诲瀷<鑷繁鐢�> + /// </summary> + public string type = string.Empty; + + + + + } + + } \ No newline at end of file diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicSourcePage.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicSourcePage.cs index 3db0642..30cae8f 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicSourcePage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicSourcePage.cs @@ -33,7 +33,7 @@ #region 鍩虹淇℃伅锛� 鎾斁鍣� 钃濈墮 鍖哄煙锛� FrameLayout fL1 = new FrameLayout { - Height = Application.GetRealHeight(202), + Height = Application.GetRealHeight(202-50), Width = Application.GetRealWidth(375), }; middViewLayout.AddChidren(fL1); @@ -50,17 +50,11 @@ View.MusicSourceView playNameView = new View.MusicSourceView(); playNameView.fLayout.Y = musicIfonView.fLayout.Bottom; playNameView.textBtn.TextID = StringId.playerName; - playNameView.inputTextBtn.Text = A31MusicModel.Current.Name; + playNameView.inputTextBtn.Text = A31MusicModel.Current.functionMusic.name; playNameView.FrameLayoutView(fL1, false); - View.MusicSourceView bluetoothNameView = new View.MusicSourceView(); - bluetoothNameView.fLayout.Y = playNameView.fLayout.Bottom; - bluetoothNameView.textBtn.TextID = StringId.bluetoothName; - bluetoothNameView.inputTextBtn.Text = A31MusicModel.Current.Name; - bluetoothNameView.FrameLayoutView(fL1, false); - View.MusicSourceView areaText = new View.MusicSourceView(); - areaText.fLayout.Y = bluetoothNameView.fLayout.Bottom; + areaText.fLayout.Y = playNameView.fLayout.Bottom; areaText.FrameLayoutView(fL1, false); areaText.nextLevelBtn.X = Application.GetRealWidth(339); areaText.nextLevelBtn.Y = Application.GetRealHeight(17); @@ -70,7 +64,7 @@ areaText.lineBtn.BackgroundColor = MusicColor.WhiteColor; areaText.textBtn.X = Application.GetRealWidth(16); areaText.textBtn.TextID = StringId.region; - areaText.inputTextBtn.Text = A31MusicModel.Current.GetRoomListName(); + areaText.inputTextBtn.Text = A31MusicModel.Current.functionMusic.GetRoomListName(); #endregion @@ -80,7 +74,7 @@ Height = Application.GetRealHeight(152), Width = Application.GetRealWidth(375), }; - middViewLayout.AddChidren(fL2); + //middViewLayout.AddChidren(fL2); View.MusicSourceView playListView = new View.MusicSourceView(); playListView.fLayout.Height = Application.GetRealHeight(44); @@ -122,41 +116,25 @@ selectedSourceView.nextLevelBtn.Visible = false; selectedSourceView.FrameLayoutView(fL3, false); - View.MusicSourceView localMusicSourceView = new View.MusicSourceView(); - localMusicSourceView.fLayout.Y = selectedSourceView.fLayout.Bottom; - localMusicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/localMusic.png"; - localMusicSourceView.textBtn.TextID = StringId.localMusic; - localMusicSourceView.FrameLayoutView(fL3); + View.MusicSourceView musicSourceView = new View.MusicSourceView(); + musicSourceView.fLayout.Y = selectedSourceView.fLayout.Bottom; + musicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/localMusic.png"; + musicSourceView.textBtn.TextID = StringId.localMusic; + musicSourceView.FrameLayoutView(fL3); - View.MusicSourceView usbSourceView = new View.MusicSourceView(); - usbSourceView.fLayout.Y = localMusicSourceView.fLayout.Bottom; - usbSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/usb.png"; - usbSourceView.textBtn.TextID = StringId.usb; - usbSourceView.FrameLayoutView(fL3); - - View.MusicSourceView radioSourceView = new View.MusicSourceView(); - radioSourceView.fLayout.Y = usbSourceView.fLayout.Bottom; - radioSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/radio.png"; - radioSourceView.textBtn.TextID = StringId.radio; - //radioSourceView.FrameLayoutView(fL3);鏆傛椂闅愯棌鍦ㄧ嚎鐢靛彴 - - View.MusicSourceView qqMusicSourceView = new View.MusicSourceView(); - qqMusicSourceView.fLayout.Y = usbSourceView.fLayout.Bottom; - qqMusicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/qqMusic.png"; - qqMusicSourceView.textBtn.TextID = StringId.qqMusic; - qqMusicSourceView.FrameLayoutView(fL3); + View.MusicSourceView bluetoothSourceView = new View.MusicSourceView(); - bluetoothSourceView.fLayout.Y = qqMusicSourceView.fLayout.Bottom; + bluetoothSourceView.fLayout.Y = musicSourceView.fLayout.Bottom; bluetoothSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/bluetooth.png"; bluetoothSourceView.textBtn.TextID = StringId.bluetooth; - bluetoothSourceView.FrameLayoutView(fL3); + //bluetoothSourceView.FrameLayoutView(fL3); View.MusicSourceView lineSourceView = new View.MusicSourceView(); lineSourceView.fLayout.Y = bluetoothSourceView.fLayout.Bottom; lineSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/line.png"; lineSourceView.textBtn.TextID = StringId.line; - lineSourceView.FrameLayoutView(fL3); + //lineSourceView.FrameLayoutView(fL3); #endregion @@ -164,34 +142,69 @@ #endregion #region 鎵�鏈夌偣鍑讳簨浠� + ///浜嬩欢 + musicSourceView.clickBtn.MouseUpEventHandler += (sender, e) => + { + A31MusicFileList a31MusicFileList = new A31MusicFileList(); + MainPage.BasePageView.AddChidren(a31MusicFileList); + a31MusicFileList.Show(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + Loading loading = new Loading(); + a31MusicFileList.AddChidren(loading); + loading.Start(); + System.Threading.Tasks.Task.Run(() => + { + try + { + if (A31MusicModel.Current.palyLists.Count == 0) + { + SendMethod.mMethod.GetPalyList(A31MusicModel.Current.functionMusic); + + } + } + catch + { + } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + a31MusicFileList.FileView(); + }); + } + }); + }; + + ///鎾斁鍣ㄤ慨鏀瑰悕绉颁簨浠� playNameView.clickBtn.MouseUpEventHandler += (sender, e) => { - new View.TipView().InputBox(StringId.modifyName, A31MusicModel.Current.Name, StringId.nameNull, (playerName) => + new View.TipView().InputBox(StringId.modifyName, A31MusicModel.Current.functionMusic.name, StringId.nameNull, (playerName) => { playNameView.inputTextBtn.Text = playerName; - A31MusicModel.Current.Name = playerName; - string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setDeviceName:" + A31MusicModel.Current.Name; - SendMethod.SendCommand(url); + A31MusicModel.Current.functionMusic.name = playerName; + //鍙戦�佸懡浠� + System.Threading.Tasks.Task.Run(() => + { + try + { + SendMethod.mMethod.EditDeviceName(A31MusicModel.Current.functionMusic.deviceId,playerName); + } + catch { } + + }); + }); }; - ///钃濈墮淇敼鍚嶇О浜嬩欢 - bluetoothNameView.clickBtn.MouseUpEventHandler += (sender, e) => - { - new View.TipView().InputBox(StringId.modifyName, A31MusicModel.Current.Name, StringId.nameNull, (bluetoothName) => - { - bluetoothNameView.inputTextBtn.Text = bluetoothName; - SendMethod.ModifyBluetoothName("MCU+PAS+BT" + bluetoothName.Trim() + "*&"); - }); - - }; + ///鍖哄煙淇敼鐨勪簨浠� areaText.clickBtn.MouseUpEventHandler += (sender, e) => { - ChooseRoomPage chooseRoomPage = new ChooseRoomPage(A31MusicModel.Current, () => + ChooseRoomPage chooseRoomPage = new ChooseRoomPage(A31MusicModel.Current.functionMusic, () => { - areaText.inputTextBtn.Text = A31MusicModel.Current.GetRoomListName(); + areaText.inputTextBtn.Text = A31MusicModel.Current.functionMusic.GetRoomListName(); A31MusicModel.Save(); }); MainPage.BasePageView.AddChidren(chooseRoomPage); @@ -223,117 +236,19 @@ a31MyList.UpdateSelectedFile(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; - ///鏈湴闊充箰浜嬩欢 - localMusicSourceView.clickBtn.MouseUpEventHandler += (sender, e) => - { - A31LocalMusicList a31LocalMusicList = new A31LocalMusicList(); - MainPage.BasePageView.AddChidren(a31LocalMusicList); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - a31LocalMusicList.Show(); - a31LocalMusicList.UpdateSelectedMusic(); - }; - ///USB浜嬩欢 - usbSourceView.clickBtn.MouseUpEventHandler += (sender, e) => - { - A31USBMusicList usbMusic = new A31USBMusicList(); - MainPage.BasePageView.AddChidren(usbMusic); - usbMusic.UIView(); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - Loading loading = new Loading(); - usbMusic.AddChidren(loading); - loading.Start(); - System.Threading.Tasks.Task.Run(() => - { - try - { - if (A31MusicModel.Current.USBList.Count == 0) - { - //杩涙潵璇讳竴娆�(娉ㄦ剰:鎾斁鍦板潃鍙兘浼氭敼鍙橈紝瀵艰嚧鎾斁涓嶄簡闊充箰;瑙e喅:杩涙潵閮藉幓鍘昏鍙栨渶鏂版暟鎹�) - var list = SendMethod.GetUsbList(A31MusicModel.Current); - A31MusicModel.Current.USBList.AddRange(list); - } - } - catch - { - } - finally - { - Application.RunOnMainThread(() => - { - loading.Hide(); - usbMusic.Show(); - usbMusic.UpdateSelectedMusic(); - }); - } - }); - }; - ///鍦ㄧ嚎鐢靛彴浜嬩欢 - radioSourceView.clickBtn.MouseUpEventHandler += (sender, e) => - { - Loading loading = new Loading(); - this.AddChidren(loading); - loading.Start(); - System.Threading.Tasks.Task.Run(() => - { - var radioList = SendMethod.ReadRadioList("http://opml.radiotime.com/Browse.ashx?partnerId=yvcOjvJP"); - Application.RunOnMainThread(() => - { - loading.Hide(); - A31Radio a31Radio = new A31Radio(); - MainPage.BasePageView.AddChidren(a31Radio); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - a31Radio.Show(radioList); - }); - }); - }; - - ///QQ闊充箰浜嬩欢 - qqMusicSourceView.clickBtn.MouseUpEventHandler += (sender, e) => - { - //string str = "com.tencent.qqmusic"; - //if (Application.DeviceType == Device.Ios) - //{ - // str = "qqmusic:"; - //} - //CommonClass.OpenApp(str); - - bool bol = false; - string url = ""; - try - { -#if __IOS__ - bol = HDLUtils.OpenApp("qqmusic://"); - url = "https://apps.apple.com/cn/app/qq%E9%9F%B3%E4%B9%90-%E8%AE%A9%E7%94%9F%E6%B4%BB%E5%85%85%E6%BB%A1%E9%9F%B3%E4%B9%90/id414603431"; - -#else - bol = HDLUtils.OpenAppWithPackageName("com.tencent.qqmusic"); - //url = "http://music.qq.com/"; - url = "market://details?id=com.tencent.qqmusic"; -#endif - if (!bol) - { - new View.TipView().TipBox1(StringId.tip, StringId.qqMsuicTip, () => - { - HDLUtils.OpenUrl(url); - }); - } - } - catch { } - }; + + + ///钃濈墮浜嬩欢 bluetoothSourceView.clickBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); - string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:switchmode:bluetooth"; - SendMethod.SendCommand(url); }; ///绾胯矾杈撳叆浜嬩欢 lineSourceView.clickBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); - string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:switchmode:line-in"; - SendMethod.SendCommand(url); }; diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MyList.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MyList.cs index 2e8ac86..fa2a7c6 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MyList.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MyList.cs @@ -101,71 +101,7 @@ UnSelectedImagePath = "MusicIcon/fileList.png", }; addFlieRow.AddChidren(fileIconBtn); - //鎾斁/鏆傚仠鍥炬爣 - Button playIconBtn = new Button - { - X = Application.GetRealWidth(78), - Y = Application.GetRealHeight(70), - Width = Application.GetRealWidth(24), - Height = Application.GetRealWidth(24), - UnSelectedImagePath = "MusicIcon/filePause.png", - SelectedImagePath = "MusicIcon/filePlay.png", - Tag= list, - }; - addFlieRow.AddChidren(playIconBtn); - - playIconBtn.MouseUpEventHandler = (sender, e) => - { - - - - ///鏌ユ壘褰撳墠鎾斁闊充箰鏄惁杩欎釜鍒楄〃 - if (playIconBtn.IsSelected) - { - if (list.ListName == A31MusicModel.Current.A31PlayStatus.Artist && A31MusicModel.Current.A31PlayStatus.status == "play") - { - - SendMethod.Pause(A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.status = "pause"; - } - - } - else - { - if (list.MusicInfoList.Count == 0) - { - return; - } - - if (list.ListName == A31MusicModel.Current.A31PlayStatus.Artist && A31MusicModel.Current.A31PlayStatus.status != "play") - { - SendMethod.Play(A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.status = "play"; - } - else - { - ///鍙栭殢鏈烘暟; - var ra = new Random { }.Next(0, list.MusicInfoList.Count); - ///鏌ユ壘褰撳墠鐨勯煶涔�; - var songs = list.MusicInfoList[ra]; - //鐐瑰嚮鎸夐挳闅忔満鎾斁闊充箰 - System.Threading.Tasks.Task.Run(() => - { - System.Threading.Thread.Sleep(50); - Application.RunOnMainThread(() => - { - //绉婚櫎鐣岄潰 - System.Threading.Tasks.Task.Run(() => - { - SendMethod.PushList(songs, list.ListName, list.MusicInfoList,A31MusicModel.Current, "鎴戠殑鍒楄〃"); - }); - }); - }); - } - - } - - }; + //鏂囦欢鍚嶆帶浠� Button fileNameBtn = new Button { @@ -268,14 +204,14 @@ var playBtn = (Button)view.GetChildren(1);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button var listIfon = playBtn.Tag as FileListInfo;//寮哄埗杞崲涓篎ileListInfo绫诲瀷; ///鏌ユ壘褰撳墠鎾斁闊充箰鏄惁杩欎釜鍒楄〃 - if (A31MusicModel.Current.A31PlayStatus.Artist == listIfon.ListName && A31MusicModel.Current.A31PlayStatus.status == "play") - { - playBtn.IsSelected = true; - } - else - { - playBtn.IsSelected = false; - } + //if (A31MusicModel.Current.A31PlayStatus.Artist == listIfon.ListName && A31MusicModel.Current.A31PlayStatus.status == "play") + //{ + // playBtn.IsSelected = true; + //} + //else + //{ + // playBtn.IsSelected = false; + //} } } catch { } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MyListMusic.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MyListMusic.cs index f55fa85..0a12ab0 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MyListMusic.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MyListMusic.cs @@ -47,14 +47,14 @@ public void MusicView(FileListInfo fileListInfo) { middViewLayout.RemoveAll(); - UI2.FuntionControlView.Music.UpdateThread.playMusuc(middViewLayout,"鎴戠殑鍒楄〃", fileListInfo.ListName, fileListInfo.MusicInfoList, A31MusicModel.Current); + // A31SongPlay.SongListView(middViewLayout,fileListInfo.ListName, fileListInfo.MusicInfoList); } /// <summary> /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 /// </summary> public void UpdateSelectedMusic() { - UI2.FuntionControlView.Music.UpdateThread.updateThread(this, middViewLayout, A31MusicModel.Current); + UpdateThread.updateCurrMusicThread(this, middViewLayout, A31MusicModel.Current); } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs index d651ae9..90a7991 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,19 @@ /// 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(); @@ -74,105 +77,69 @@ 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 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); - 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)) { - //0鍒楄〃寰幆锛�1鍗曟洸寰幆锛�2闅忔満鎾斁; - case "0": - A31MusicModel.Current.A31PlayStatus.loop = "1"; + //list_cycle鍒楄〃寰幆锛宻ingle_cycle鍗曟洸寰幆锛宺andom闅忔満鎾斁; + case ValueProperty.list_cycle: + modeValueString=ValueProperty.single_cycle; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; msg += Language.StringByID(StringId.singleMode); break; - case "1": - A31MusicModel.Current.A31PlayStatus.loop = "2"; + case ValueProperty.single_cycle: + modeValueString =ValueProperty.random; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; msg += Language.StringByID(StringId.randomMode); break; - case "2": - A31MusicModel.Current.A31PlayStatus.loop = "0"; + case ValueProperty.random: + modeValueString = ValueProperty.list_cycle; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; msg += Language.StringByID(StringId.listMode); break; } + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.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(KeyProperty.mode,modeValueString); + SendMethod.mMethod.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; - if (A31MusicModel.Current.A31PlayStatus.Source == "RADIO-NETWORK") + var name = A31MusicModel.Current.functionMusic.GetAttribute("song_name").ToString(); + var songTime = A31MusicModel.Current.functionMusic.GetAttribute("song_time").ToString(); + 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 url == musicInfo.URL; - })) - { - A31MusicModel.Current.LoveRadioInfoList.Add(new MusicInfo { Title = song, URL = url, }); - } - } - else + return name == musicInfo.name; + })) { - A31MusicModel.Current.LoveRadioInfoList.RemoveAll((musicInfo) => - { - return url == musicInfo.URL; - }); + 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 url == musicInfo.URL; - })) - { - A31MusicModel.Current.LoveMusicInfoList.Add(new MusicInfo { Title = song, URL = url, Artist = artist, Album = album }); - } - } - else - { - A31MusicModel.Current.LoveMusicInfoList.RemoveAll((musicInfo) => - { - //涔熻鍔犳瓕鎵嬪悕鍒ゆ柇 - return musicInfo.URL == url; - }); - } - + //涔熻鍔犳瓕鎵嬪悕鍒ゆ柇 + return musicInfo.name == name; + }); } A31MusicModel.Save(); }; @@ -198,25 +165,18 @@ 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) => { - 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;//涔嬪墠鐨勯煶閲� @@ -227,8 +187,11 @@ if (startVolume != e) { startVolume = e; - SendMethod.ControlVolume(e, A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.vol = e.ToString(); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add(KeyProperty.volume, startVolume.ToString()); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + } }; playView.volSeekBar.OnProgressChangedEvent += progressClick; @@ -237,7 +200,12 @@ playView.prevBtn.MouseDownEventHandler += (sender, e) => { playView.prevBtn.IsSelected = true; - SendMethod.Previous(A31MusicModel.Current); + + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step,ValueProperty.down); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add(KeyProperty.song_step, ValueProperty.down); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + }; playView.prevBtn.MouseUpEventHandler += (sender, e) => { @@ -246,24 +214,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 = ValueProperty.off; } else { playView.playBtn.IsSelected = true; - SendMethod.Play(A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.status = "play"; + status = ValueProperty.on; } + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.on_off, status); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add(KeyProperty.on_off, status); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; ///涓嬩竴鏇茬偣鍑讳簨浠� playView.nextBtn.MouseDownEventHandler += (sender, e) => { playView.nextBtn.IsSelected = true; - SendMethod.Next(A31MusicModel.Current); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step,ValueProperty.down); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add(KeyProperty.song_step, ValueProperty.down); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; playView.nextBtn.MouseUpEventHandler += (sender, e) => { @@ -272,7 +246,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; } @@ -281,8 +255,10 @@ if (startVolume != volume) { startVolume = volume; - SendMethod.ControlVolume(volume, A31MusicModel.Current); - A31MusicModel.Current.A31PlayStatus.vol = volume.ToString(); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add(KeyProperty.volume, startVolume.ToString()); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); } }; @@ -305,10 +281,9 @@ { try { - //鏇存柊鎬绘椂闂� //鎬诲叡鏈夊灏戠 - int totalSecond = int.Parse(A31MusicModel.Current.A31PlayStatus.totlen) / 1000; + int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_time))/1000; //鍒嗛挓 int totalMusicMinute = totalSecond / 60; //绉掗挓 @@ -317,54 +292,54 @@ 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; - - switch (A31MusicModel.Current.A31PlayStatus.loop) + topView.topNameBtn.Text = A31MusicModel.Current.functionMusic.name; + string s = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode); + switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode)) { - case "0"://鍒楄〃寰幆 + case ValueProperty.list_cycle://鍒楄〃寰幆 playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; break; - case "1"://鍗曟洸椤虹幆 + case ValueProperty.single_cycle://鍗曟洸寰幆 playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; break; - case "2"://闅忔満鎾斁 + case ValueProperty.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; } @@ -392,14 +367,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; - //褰撳墠鎾斁闊充箰鏃堕棿 - int playSecond = int.Parse(A31MusicModel.Current.A31PlayStatus.curpos) / 1000 + (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; + //褰撳墠鎾斁闊充箰鏃堕棿 + //鎸夐亾鐞嗕笉浼氫负绌猴紝GetAttrState("playing_time")鍊煎彲鑳戒负绌猴紝寮哄埗杞崲int.Parse(锛変細鍑虹幇寮傚父锛屼笉杩囦篃鍋氫簡寮傚父澶勭悊浜� + int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playing_time))+ (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; int playMusicMinute = playSecond / 60; //绉掗挓 @@ -407,7 +383,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(KeyProperty.on_off) == ValueProperty.on) { playView.playBtn.IsSelected = true; //濡傛灉鍦ㄦ挱鏀撅紝鏃堕棿灏变笉鏂彉鍖� @@ -423,6 +399,7 @@ playView.diyArcSeekBar.Progress = (int)(playSecond * 100.0 / totalSecond);//+1 } + } else { @@ -430,10 +407,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(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(); + // showSourcePage(); } catch (Exception e) { @@ -469,7 +446,7 @@ playView.diyArcSeekBar.IsClickable = true; - switch (A31MusicModel.Current.A31PlayStatus.Source) + switch (A31MusicModel.Current.functionMusic.GetAttrState("source")) { case "QPLAY"://QQ闊充箰 @@ -539,91 +516,51 @@ /// 鍔犺浇鎾斁闊充箰鍒楄〃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.GetAttrState(KeyProperty.playlist_name); + var musicList = A31MusicModel.Current.GetSongList(listName); + 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.updateThread(frameLayout, middViewLayout, A31MusicModel.Current); + 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); - }); - } - }); - } + + } } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayStatus.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayStatus.cs deleted file mode 100644 index c3dc326..0000000 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayStatus.cs +++ /dev/null @@ -1,34 +0,0 @@ -锘縰sing System; -namespace HDL_ON.UI.Music -{ - /// <summary> - /// A3闊充箰鎾斁鐘舵�� - /// </summary> - [System.Serializable] - public class A31PlayStatus - { - public string type = "0"; - public string ch = "0"; - public string mode = "0"; - public string loop = "0"; - public string status = "stop"; - public string curpos = "0"; - public string totlen = "0"; - public string Title = "Unkonw"; - public string Artist = "Unkonw"; - public string Album = "Unkonw"; - public string plicount = "0"; - public string plicurr = "0"; - public string vol = "0"; - public string Source = "0"; - public string TrackURL = ""; - public string playSource = ""; - public bool IsMute - { - get - { - return vol == "0"; - } - } - } -} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31Radio.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31Radio.cs deleted file mode 100644 index bd119b9..0000000 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31Radio.cs +++ /dev/null @@ -1,240 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Xml; -using Shared; -namespace HDL_ON.UI.Music -{ - public class A31Radio : FrameLayout - { - public A31Radio() - { - Tag = "Music"; - - } - - VerticalRefreshLayout middViewLayout; - /// <summary> - /// 鍏堝姞杞界晫闈㈠嚭鏉� - /// </summary> - public void Show(string date) - { - InitList(date); - #region 鐣岄潰甯冨眬------ - this.BackgroundColor = MusicColor.ViewColor; - var topView = new TopView(); - this.AddChidren(topView.TopFLayoutView()); - topView.topNameBtn.TextID = StringId.radio; - topView.clickBackBtn.MouseUpEventHandler += (sender, e) => - { - this.RemoveFromParent(); - }; - middViewLayout = new VerticalRefreshLayout - { - BackgroundColor = MusicColor.WhiteColor, - Y = topView.fLayout.Bottom, - Height = Application.GetRealHeight(H_W.H - H_W.T_Height), - }; - this.AddChidren(middViewLayout); - middViewLayout.BeginHeaderRefreshingAction += () => - { - middViewLayout.EndHeaderRefreshing(); - }; - #endregion - RadioListView(); - } - /// <summary> - /// 鍔犺浇鏁版嵁鐨勬柟娉� - /// </summary> - public void RadioListView() - { - - middViewLayout.RemoveAll(); - for (int i = 0; i < A31MusicModel.Current.CnRadioInfoList.Count; i++) - { - var radioInfo = A31MusicModel.Current.CnRadioInfoList[i]; - RowLayout addFlieRow = new RowLayout - { - Height = Application.GetRealHeight(78), - LineColor = MusicColor.WhiteColor, - SubViewWidth = Application.GetRealWidth(90),//鏀瑰彉缂栬緫鎺т欢瀹藉害澶氬皯锛� - }; - middViewLayout.AddChidren(addFlieRow); - //鏂囦欢鍥炬爣 - Button fileIconBtn = new Button - { - X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(8), - Width = Application.GetRealWidth(62), - Height = Application.GetRealWidth(62), - UnSelectedImagePath = "MusicIcon/file.png", - }; - addFlieRow.AddChidren(fileIconBtn); - //鏂囦欢鍚嶆帶浠� - Button fileNameBtn = new Button - { - X = fileIconBtn.Right + Application.GetRealWidth(16), - Y = Application.GetRealHeight(29), - Width = Application.GetRealWidth(220), - Height = Application.GetRealHeight(20), - TextColor = MusicColor.TextColor, - TextSize = TextSize.Text14, - TextAlignment = TextAlignment.CenterLeft, - Text = radioInfo.Title, - }; - addFlieRow.AddChidren(fileNameBtn); - - - Button clickBtn = new Button - { - X = fileIconBtn.Right + Application.GetRealWidth(16), - Width = Application.GetRealWidth(375 - 94), - Height = Application.GetRealHeight(78), - Tag = radioInfo.URL, - }; - addFlieRow.AddChidren(clickBtn); - clickBtn.MouseUpEventHandler += (sender, e) => - { - - Loading loading = new Loading(); - this.AddChidren(loading); - loading.Start(); - System.Threading.Tasks.Task.Run(() => - { - try - { - var dataString = SendMethod.ReadRadioList(clickBtn.Tag.ToString()); - if (dataString == null) - { - return; - } - int startIndex1=dataString.IndexOf("<body>"); - int endIndex1 = dataString.IndexOf("</body>") + "</body>".Length; - if (endIndex1 <= startIndex1) - { - return; - } - - XmlDocument xml1 = new XmlDocument(); - xml1.LoadXml(dataString.Substring(startIndex1, endIndex1 - startIndex1)); - var dataList = xml1.SelectSingleNode("body"); - if (dataList == null) - { - return; - } - A31MusicModel.Current.CnRadioInfoList.Clear(); - foreach (XmlNode childNodes in dataList.ChildNodes) - { - if (childNodes.Name == "outline" && childNodes.Attributes["URL"] != null) - { - MusicInfo musicInfoCN = new MusicInfo(); - musicInfoCN.URL = childNodes.Attributes["URL"] == null ? "" : childNodes.Attributes["URL"].Value; - musicInfoCN.Title = childNodes.Attributes["text"] == null ? "" : childNodes.Attributes["text"].Value; - musicInfoCN.Image = childNodes.Attributes["image"] == null ? "" : childNodes.Attributes["image"].Value; - if (childNodes.Attributes["image"] != null) - { - string path = ""; - if (Shared.Application.IsPad) - { - path = ""; - } - else - { - path = "Phone/" + "MusicImage/"; - } - } - musicInfoCN.Cntype = childNodes.Attributes["type"] == null ? "" : childNodes.Attributes["type"].Value; - A31MusicModel.Current.CnRadioInfoList.Add(musicInfoCN); - } - foreach (XmlNode a in childNodes.ChildNodes) - { - if (a.Name == "outline") - { - MusicInfo musicInfoCN = new MusicInfo(); - musicInfoCN.URL = a.Attributes["URL"] == null ? "" : a.Attributes["URL"].Value; - musicInfoCN.Title = a.Attributes["text"] == null ? "" : a.Attributes["text"].Value; - - if (a.Attributes["image"] != null) - { - #region 鍒濆鍖栫綉缁滃浘鐗囪矾寰� - string path = ""; - if (Shared.Application.IsPad) - { - path = "Pad/" + "MusicImage/"; - } - else - { - path = "Phone/" + "MusicImage/"; - } - path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, path + a.Attributes["image"].Value.Replace('/', '_').Replace('\\', '_').Replace(':', '_').Replace('*', '_').Replace('?', '_').Replace('"', '_').Replace('<', '_').Replace('>', '_').Replace('|', '_')); - musicInfoCN.Image = path; - #endregion - //Shared.IO.FileUtils.DownLoadImage(musicInfoCN.Image, a.Attributes["image"].Value); - } - musicInfoCN.Cntype = a.Attributes["type"] == null ? "" : a.Attributes["type"].Value; - A31MusicModel.Current.CnRadioInfoList.Add(musicInfoCN); - - } - } - } - } - catch { } - finally - { - Application.RunOnMainThread(() => - { - loading.Hide(); - A31RadioList a31RadioList = new A31RadioList(); - MainPage.BasePageView.AddChidren(a31RadioList); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - a31RadioList.Show(fileNameBtn.Text); - }); - } - }); - }; - - } - } - - void InitList(string data) - { - try - { - var readString = data; - if (readString == null) - { - return; - } - int startIndex1 = readString.IndexOf("<body>"); - int endIndex = readString.IndexOf("</body>") + "</body>".Length; - if (endIndex <= startIndex1) - { - return; - } - var aa = readString.Substring(startIndex1, endIndex - startIndex1); - XmlDocument xml = new XmlDocument(); - xml.LoadXml(aa); - var CNList = xml.SelectSingleNode("body"); - if (CNList == null) - { - return; - } - A31MusicModel.Current.CnRadioInfoList.Clear(); - foreach (XmlNode v in CNList.ChildNodes) - { - switch (v.Name) - { - case "outline": - MusicInfo musicInfo = new MusicInfo(); - musicInfo.Title = v.Attributes["text"].Value; - musicInfo.URL = v.Attributes["URL"].Value; - musicInfo.Cnkey = v.Attributes["key"].Value; - - A31MusicModel.Current.CnRadioInfoList.Add(musicInfo); - break; - } - } - } - catch { } - } - } -} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31RadioList.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31RadioList.cs deleted file mode 100644 index 9ad5b09..0000000 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31RadioList.cs +++ /dev/null @@ -1,433 +0,0 @@ -锘縰sing System; -using System.Net; -using System.Text; -using System.Xml; -using Shared; -namespace HDL_ON.UI.Music -{ - public class A31RadioList : FrameLayout - { - public A31RadioList() - { - Tag = "Music"; - } - - VerticalRefreshLayout middViewLayout; - /// <summary> - /// 鍏堝姞杞界晫闈㈠嚭鏉� - /// </summary> - public void Show(string listName) - { - - #region 鐣岄潰甯冨眬------ - this.BackgroundColor = MusicColor.ViewColor; - var topView = new TopView(); - this.AddChidren(topView.TopFLayoutView()); - topView.topNameBtn.Text= listName; - topView.clickBackBtn.MouseUpEventHandler += (sender, e) => - { - this.RemoveFromParent(); - }; - middViewLayout = new VerticalRefreshLayout - { - BackgroundColor = MusicColor.WhiteColor, - Y = topView.fLayout.Bottom, - Height = Application.GetRealHeight(H_W.H - H_W.T_Height), - }; - this.AddChidren(middViewLayout); - middViewLayout.BeginHeaderRefreshingAction += () => - { - middViewLayout.EndHeaderRefreshing(); - }; - #endregion - MusicView(listName); - } - /// <summary> - /// 鍔犺浇鏁版嵁鐨勬柟娉� - /// </summary> - public void MusicView(string listName) - { - middViewLayout.RemoveAll(); - for (int i = 0; i < A31MusicModel.Current.CnRadioInfoList.Count; i++) - { - var radioInfo = A31MusicModel.Current.CnRadioInfoList[i]; - #region Audio (鎾斁鍒楄〃) - if (radioInfo.Cntype == "audio") - { - - if (string.IsNullOrEmpty(radioInfo.Title)) - { - //闃叉姝屾洸鍚嶅瓧涓虹┖鎶涘紓甯� - radioInfo.Title = " "; - } - FrameLayout radioViewFl = new FrameLayout - { - Width = Application.GetRealWidth(375), - Height = Application.GetRealHeight(67), - }; - middViewLayout.AddChidren(radioViewFl); - //榛樿鐢靛彴鍥炬爣 - Button radioIconBtn = new Button - { - X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(18), - Width = Application.GetRealWidth(32), - Height = Application.GetRealWidth(32), - UnSelectedImagePath = "MusicIcon/radioIcon.png", - }; - radioViewFl.AddChidren(radioIconBtn); - //鐢靛彴鍚嶇О - Button radioNameBtn = new Button - { - X = Application.GetRealWidth(60), - Y = Application.GetRealHeight(23), - Width = Application.GetRealWidth(250), - Height = Application.GetRealHeight(22), - TextColor = MusicColor.MusicTxet14Color, - TextSize = TextSize.Text16, - TextAlignment = TextAlignment.CenterLeft, - Tag = radioInfo.URL, - Text = radioInfo.Title.Trim() - }; - radioViewFl.AddChidren(radioNameBtn); - - //娣诲姞鍠滅埍鐢靛彴 - Button loveIcon = new Button - { - X = Application.GetRealWidth(335), - Y = Application.GetRealHeight(20), - Width = Application.GetRealWidth(28), - Height = Application.GetRealWidth(28), - UnSelectedImagePath = "MusicIcon/love.png", - SelectedImagePath = "MusicIcon/loveSelected.png", - }; - radioViewFl.AddChidren(loveIcon); - loveIcon.MouseUpEventHandler += (sender, e) => - { - loveIcon.IsSelected = !loveIcon.IsSelected; - if (loveIcon.IsSelected) - { - ///鏌ユ壘鐢靛彴鏄惁瀛樺湪鍦ㄥ垪琛� - var radioselected= A31MusicModel.Current.LoveRadioInfoList.Find((m) => m.URL == radioInfo.URL); - if (radioselected == null) - { - ///娌℃湁瀛樺湪灏辨坊鍔� - A31MusicModel.Current.LoveRadioInfoList.Add(radioInfo); - } - } - else - { - ///鏌ユ壘闊崇數鍙版槸鍚﹀瓨鍦ㄥ湪鍒楄〃 - var radioselected = A31MusicModel.Current.LoveRadioInfoList.Find((m) => m.URL == radioInfo.URL); - if (radioselected != null) - { - ///瀛樺湪灏卞垹闄� - A31MusicModel.Current.LoveRadioInfoList.Remove(radioInfo); - } - - } - A31MusicModel.Save(); - }; - var v = A31MusicModel.Current.LoveRadioInfoList.Find((m) => m.URL == radioInfo.URL); - if (v != null) - { - loveIcon.IsSelected = true; - } - else - { - loveIcon.IsSelected = false; - } - - //鐐瑰嚮鎺т欢 - Button clickBtn = new Button - { - Width = Application.GetRealWidth(280), - Height = Application.GetRealHeight(44), - Tag = radioInfo,//鏍囪鎾斁鍝竴棣栨瓕鏇� - }; - radioViewFl.AddChidren(clickBtn); - ///鐐瑰嚮鎾斁浜嬩欢 - clickBtn.MouseUpEventHandler += (sender, e) => - { - - System.Threading.Tasks.Task.Run(() => - { - System.Threading.Thread.Sleep(50); - Application.RunOnMainThread(() => - { - //绉婚櫎鐣岄潰 - A31MusicModel.Current.A31PlayStatus.Title = radioNameBtn.Text; - MainPage.BasePageView.RemoveViewByTag("Music"); - System.Threading.Tasks.Task.Run(() => - { - PushList(clickBtn.Tag as MusicInfo, listName); - }); - }); - }); - - }; - - } - #endregion - - #region Link(鍒楄〃) - if (radioInfo.Cntype == "link") - { - RowLayout addFlieRow = new RowLayout - { - Height = Application.GetRealHeight(78), - LineColor = MusicColor.WhiteColor, - SubViewWidth = Application.GetRealWidth(90),//鏀瑰彉缂栬緫鎺т欢瀹藉害澶氬皯锛� - }; - middViewLayout.AddChidren(addFlieRow); - //鏂囦欢鍥炬爣 - Button fileIconBtn = new Button - { - X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(8), - Width = Application.GetRealWidth(62), - Height = Application.GetRealWidth(62), - UnSelectedImagePath = "MusicIcon/file.png", - }; - addFlieRow.AddChidren(fileIconBtn); - //鏂囦欢鍚嶆帶浠� - Button fileNameBtn = new Button - { - X = fileIconBtn.Right + Application.GetRealWidth(16), - Y = Application.GetRealHeight(29), - Width = Application.GetRealWidth(220), - Height = Application.GetRealHeight(20), - TextColor = MusicColor.TextColor, - TextSize = TextSize.Text14, - TextAlignment = TextAlignment.CenterLeft, - Text = radioInfo.Title, - }; - addFlieRow.AddChidren(fileNameBtn); - - Button clickBtn = new Button - { - X = fileIconBtn.Right + Application.GetRealWidth(16), - Width = Application.GetRealWidth(375 - 94), - Height = Application.GetRealHeight(78), - Tag = radioInfo.URL, - }; - addFlieRow.AddChidren(clickBtn); - clickBtn.MouseUpEventHandler += (sender, e) => - { - Loading loading = new Loading(); - this.AddChidren(loading); - loading.Start(); - System.Threading.Tasks.Task.Run(() => - { - try - { - var redString = SendMethod.ReadRadioList(clickBtn.Tag.ToString()); - if (redString == null) - { - return; - } - int startIndex2 = redString.IndexOf("<body>"); - int endIndex = redString.IndexOf("</body>") + "</body>".Length; - if (endIndex <= startIndex2) - { - return; - } - var ss = redString.Substring(startIndex2, endIndex - startIndex2); - XmlDocument xml = new XmlDocument(); - xml.LoadXml(ss); - var listString = xml.SelectSingleNode("body"); - if (listString == null) - { - return; - } - A31MusicModel.Current.CnRadioInfoList.Clear(); - foreach (XmlNode childNodes in listString.ChildNodes) - { - if (childNodes.Name == "outline" && childNodes.Attributes["URL"] != null) - { - MusicInfo musicInfoCN = new MusicInfo(); - musicInfoCN.URL = childNodes.Attributes["URL"] == null ? "" : childNodes.Attributes["URL"].Value; - musicInfoCN.Title = childNodes.Attributes["text"] == null ? "" : childNodes.Attributes["text"].Value; - //musicInfoCN.Image = childNodes.Attributes["image"] == null ? "" : childNodes.Attributes["image"].Value; - - if (childNodes.Attributes["image"] != null) - { - #region 鍒濆鍖栫綉缁滃浘鐗囪矾寰� - string path = ""; - if (Shared.Application.IsPad) - { - path = "Pad/" + "MusicImage/"; - } - else - { - path = "Phone/" + "MusicImage/"; - } - path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, path + childNodes.Attributes["image"].Value.Replace('/', '_').Replace('\\', '_').Replace(':', '_').Replace('*', '_').Replace('?', '_').Replace('"', '_').Replace('<', '_').Replace('>', '_').Replace('|', '_')); - musicInfoCN.Image = path; - #endregion - //Shared.IO.FileUtils.DownLoadImage(musicInfoCN.Image, childNodes.Attributes["image"].Value); - } - - musicInfoCN.Cntype = childNodes.Attributes["type"] == null ? "" : childNodes.Attributes["type"].Value; - A31MusicModel.Current.CnRadioInfoList.Add(musicInfoCN); - } - foreach (XmlNode a in childNodes.ChildNodes) - { - if (a.Name == "outline") - { - MusicInfo musicInfoCN = new MusicInfo(); - musicInfoCN.URL = a.Attributes["URL"] == null ? "" : a.Attributes["URL"].Value; - musicInfoCN.Title = a.Attributes["text"] == null ? "" : a.Attributes["text"].Value; - if (a.Attributes["image"] != null) - { - #region 鍒濆鍖栫綉缁滃浘鐗囪矾寰� - string path = ""; - if (Shared.Application.IsPad) - { - path = "Pad/" + "MusicImage/"; - } - else - { - path = "Phone/" + "MusicImage/"; - } - path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, path + a.Attributes["image"].Value.Replace('/', '_').Replace('\\', '_').Replace(':', '_').Replace('*', '_').Replace('?', '_').Replace('"', '_').Replace('<', '_').Replace('>', '_').Replace('|', '_')); - musicInfoCN.Image = path; - #endregion - // Shared.IO.FileUtils.DownLoadImage(musicInfoCN.Image, a.Attributes["image"].Value); - } - musicInfoCN.Cntype = a.Attributes["type"] == null ? "" : a.Attributes["type"].Value; - A31MusicModel.Current.CnRadioInfoList.Add(musicInfoCN); - } - } - } - } - catch { } - finally - { - Application.RunOnMainThread(() => - { - loading.Hide(); - A31RadioList a31RadioList = new A31RadioList(); - MainPage.BasePageView.AddChidren(a31RadioList); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - a31RadioList.Show(fileNameBtn.Text); - }); - } - }); - }; - } - #endregion - - } - } - - public void PushList(MusicInfo musicInfo, string listName) - { - StringBuilder sb = new StringBuilder(); - sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>"); - sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - sb.AppendLine("<s:Body>"); - sb.AppendLine("<u:CreateQueue xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">"); - sb.AppendLine("<QueueContext>"); - sb.AppendLine("<?xml version="1.0" ?>"); - sb.AppendLine("<PlayList>"); - sb.AppendLine("<ListName>" + listName + "</ListName>"); - sb.AppendLine("<ListInfo>"); - sb.AppendLine("<Radio>1</Radio>"); - sb.AppendLine("<SourceName>TuneIn</SourceName>"); - sb.AppendLine("<TrackNumber>1</TrackNumber>"); - sb.AppendLine("<SearchUrl>http://opml.radiotime.com/Tune.ashx?id=s112201&amp;partnerId=yvcOjvJP</SearchUrl>"); - sb.AppendLine("<Quality>3</Quality>"); - sb.AppendLine("<RealIndex>0</RealIndex>"); - sb.AppendLine("<SrcParent></SrcParent>"); - sb.AppendLine("<PicUrl></PicUrl>"); - sb.AppendLine("</ListInfo>"); - sb.AppendLine("<Tracks>"); - - - var url =SendMethod.ReadRadioList(musicInfo.URL); - - if (url != null) - { - url = url.TrimEnd('\n').Replace("&", "&amp;"); - } - else - { - return; - } - - sb.AppendLine("<Track" + 1 + ">"); - sb.AppendLine("<Source>TuneIn</Source>"); - sb.AppendLine("<URL>" + url + "</URL>"); - sb.AppendLine("<Source>TuneIn</Source>"); - sb.AppendLine("<Id>0</Id>"); - sb.AppendLine("<Key>http://so.ard.iyyin.com/s/song_with_out?q=%E8%8A%B1%E9%83%BD%E7%94%B5%E5%8F%B0+100.5+%28%E6%B5%81%E8%A1%8C%E9%9F%B3%E4%B9%90%E5%89%8D40%29%20TuneIn&amp;size=50&amp;page=1</Key>"); - sb.AppendLine("<Metadata>"); - sb.AppendLine("&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:song=&quot;www.wiimu.com/song/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;"); - sb.AppendLine("&lt;upnp:class&gt;object.item.audioItem.musicTrack&lt;/upnp:class&gt;"); - sb.AppendLine("&lt;item&gt;"); - sb.AppendLine("&lt;song:bitrate&gt;0&lt;/song:bitrate&gt;"); - sb.AppendLine("&lt;song:id&gt;0&lt;/song:id&gt;"); - sb.AppendLine("&lt;song:singerid&gt;0&lt;/song:singerid&gt;"); - sb.AppendLine("&lt;song:albumid&gt;0&lt;/song:albumid&gt;"); - sb.AppendLine("&lt;res protocolInfo=&quot;http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;&quot; duration=&quot;1000&quot;&gt;" + url + "&lt;/res&gt;"); - sb.AppendLine("&lt;dc:title&gt;" + musicInfo.Title + "&lt;/dc:title&gt;"); - sb.AppendLine("&lt;upnp:artist&gt;TuneIn&lt;/upnp:artist&gt;"); - sb.AppendLine("&lt;upnp:album&gt;&lt;/upnp:album&gt;"); - sb.AppendLine("&lt;upnp:albumArtURI&gt;" + musicInfo.Image + "&lt;/upnp:albumArtURI&gt;"); - sb.AppendLine("&lt;/item&gt;"); - sb.AppendLine("&lt;/DIDL-Lite&gt;"); - sb.AppendLine("</Metadata>"); - sb.AppendLine("</Track" + 1 + ">"); - - - sb.AppendLine("</Tracks>"); - sb.AppendLine("</PlayList>"); - sb.AppendLine("</QueueContext>"); - sb.AppendLine("</u:CreateQueue>"); - sb.AppendLine("</s:Body>"); - sb.AppendLine("</s:Envelope>"); - //sendMusicLists(a31.IPAddress, a31.Port, "CreateQueue", sb.ToString()); - SendMusicLists(A31MusicModel.Current.IPAddress, A31MusicModel.Current.Port, "CreateQueue", sb.ToString()); - - StringBuilder playString = new StringBuilder(); - playString.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>"); - playString.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - playString.AppendLine("<s:Body>"); - playString.AppendLine("<u:PlayQueueWithIndex xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">"); - playString.AppendLine("<QueueName>" + listName + "</QueueName>"); - playString.AppendLine("<Index>" + 1 + "</Index>"); - playString.AppendLine("</u:PlayQueueWithIndex>"); - playString.AppendLine("</s:Body>"); - playString.AppendLine("</s:Envelope>"); - Play(A31MusicModel.Current.IPAddress, A31MusicModel.Current.Port, playString.ToString()); - - } - - void SendMusicLists(string ip, int port, string soapAction, string listInfo) - { - WebClient webClient = new WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#" + soapAction + "\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - byte[] recevieBytes = webClient.UploadData(new Uri("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(listInfo)); - var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); - } - catch { } - } - - void Play(string ip, int port, string info) - { - WebClient webClient = new WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#PlayQueueWithIndex\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - byte[] recevieBytes = webClient.UploadData(new Uri("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(info)); - var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); - } - catch { } - } - } -} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31SongPlay.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31SongPlay.cs new file mode 100644 index 0000000..1ec1ba3 --- /dev/null +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31SongPlay.cs @@ -0,0 +1,149 @@ +锘縰sing System; +using Shared; +using HDL_ON.UI.Music; +using System.Collections.Generic; + +namespace HDL_ON.UI.Music +{ + + public class A31SongPlay : FrameLayout + { + public A31SongPlay() + { + Tag = "Music"; + } + + public void Show(List<Songs> musicList,string listName) + { + + this.BackgroundColor = MusicColor.ViewColor; + var topView = new TopView(); + this.AddChidren(topView.TopFLayoutView()); + topView.topNameBtn.TextID = StringId.localMusic; + topView.clickBackBtn.MouseUpEventHandler += (sender, e) => + { + this.RemoveFromParent(); + }; + var vv = new VerticalRefreshLayout + { + BackgroundColor = MusicColor.WhiteColor, + Y = topView.fLayout.Bottom, + Height = Application.GetRealHeight(H_W.H - H_W.T_Height), + }; + this.AddChidren(vv); + vv.BeginHeaderRefreshingAction += () => + { + vv.EndHeaderRefreshing(); + }; + ///鍔犺浇闊充箰鍒楄〃 + SongListView(vv, musicList, listName); + + + } + /// <summary> + /// 鍔犺浇闊充箰鍒楄〃 + /// </summary> + /// <param name="vv">鐖舵帶浠�</param> + /// <param name="musicList">闊充箰鍒楄〃</param> + /// <param name="listName">鍒楄〃鍚�</param> + public static void SongListView(VerticalRefreshLayout vv,List<Songs> musicList,string listName, FrameLayout frame = null) { + + for (int i = 0; i < musicList.Count; i++) + { + var songs = musicList[i]; + if (songs == null) + { + continue; + } + UI.Music.View.SongView songView = new UI.Music.View.SongView(); + songView.SongFrameLayout(vv, songs); + songView.songBtn.Text = songs.name; + ///鐐瑰嚮鎾斁浜嬩欢 + songView.clickBtn.MouseUpEventHandler += (sender, e) => + { + System.Threading.Tasks.Task.Run(() => + { + System.Threading.Thread.Sleep(50); + Application.RunOnMainThread(() => + { + //绉婚櫎鐣岄潰 + A31MusicModel.Current.functionMusic.SetAttrState("song_name", songView.songBtn.Text); + A31MusicModel.Current.functionMusic.SetAttrState("playlist_name", listName); + //绉婚櫎鐣岄潰 + if (frame != null) + { + frame.RemoveFromParent(); + } + MainPage.BasePageView.RemoveViewByTag("Music"); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add("song_name", songView.songBtn.Text); + dic.Add("playlist_name", listName); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + }); + }); + }; + + } + + } + } + + public class UpdateThread + { + public UpdateThread() + { + } + /// <summary> + /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 + /// </summary> + /// <param name="frame">褰撳墠鐣岄潰</param> + /// <param name="middViewLayout">姣忎竴鏉¢煶涔愮殑涓绘帶浠�</param> + /// <param name="a31MusicModel">鐐瑰墠鎾斁鍣�</param> + public static void updateCurrMusicThread(FrameLayout frame, VerticalRefreshLayout middViewLayout, A31MusicModel a31MusicModel) + { + System.Threading.Thread updateSelectedMusicThread = new System.Threading.Thread(() => + { + while (frame.Parent != null) + { + //A31MusicModel.LogMusic("宸插惎鍔ㄦ洿鏂伴煶涔愬垪琛ㄦ煇涓�鏉¢煶涔愮姸鎬佺殑绾跨▼"); + System.Threading.Thread.Sleep(1000); + Application.RunOnMainThread(() => + { + try + { + for (int i = 0; i < middViewLayout.ChildrenCount; i++) + { + RowLayout view = (RowLayout)middViewLayout.GetChildren(i); + var volIconBtn = (Button)view.GetChildren(0);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button + var songNameBtn = (Button)view.GetChildren(1);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button + var artistNameBtn = (Button)view.GetChildren(2);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button + //if (a31MusicModel.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString()) + //{ + // volIconBtn.Visible = true; + // songNameBtn.TextColor = UI.Music.MusicColor.SelectedColor; + // songNameBtn.X = Application.GetRealWidth(48); + // artistNameBtn.X = songNameBtn.Right; + // artistNameBtn.TextColor = UI.Music.MusicColor.SelectedColor; + //} + //else + //{ + // volIconBtn.Visible = false; + // songNameBtn.TextColor = UI.Music.MusicColor.MusicTxet14Color; + // songNameBtn.X = Application.GetRealWidth(16); + // artistNameBtn.X = songNameBtn.Right; + // artistNameBtn.TextColor = UI.Music.MusicColor.MusicNoTxetColor; + //} + + + } + } + catch { } + + }); + } + }); + updateSelectedMusicThread.Start(); + } + + } +} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31USBMusicList.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31USBMusicList.cs deleted file mode 100644 index 3faba9c..0000000 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31USBMusicList.cs +++ /dev/null @@ -1,82 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using Shared; -namespace HDL_ON.UI.Music -{ - public class A31USBMusicList : FrameLayout - { - public A31USBMusicList() - { - Tag = "Music"; - } - - VerticalRefreshLayout middViewLayout; - /// <summary> - /// 鍏堝姞杞界晫闈㈠嚭鏉� - /// </summary> - public void UIView() - { - #region 鐣岄潰甯冨眬------ - - this.BackgroundColor = MusicColor.ViewColor; - var topView = new TopView(); - this.AddChidren(topView.TopFLayoutView()); - topView.topNameBtn.TextID = StringId.usb; - topView.clickBackBtn.MouseUpEventHandler += (sender, e) => - { - this.RemoveFromParent(); - }; - middViewLayout = new VerticalRefreshLayout - { - BackgroundColor = MusicColor.WhiteColor, - Y = topView.fLayout.Bottom, - Height = Application.GetRealHeight(H_W.H - H_W.T_Height), - }; - this.AddChidren(middViewLayout); - - middViewLayout.BeginHeaderRefreshingAction += () => - { - //System.Threading.Tasks.Task.Run(() => - //{ - // try - // { - // var list = SendMethod.GetUsbList(); - // A31MusicModel.Current.USBList.Clear(); - // A31MusicModel.Current.USBList.AddRange(list); - // } - // catch { } - // finally - // { - // Application.RunOnMainThread(() => - // { - // Show(); - // middViewLayout.EndHeaderRefreshing(); - // }); - // } - //}); - var list = SendMethod.GetUsbList(A31MusicModel.Current); - A31MusicModel.Current.USBList.Clear(); - A31MusicModel.Current.USBList.AddRange(list); - Show(); - middViewLayout.EndHeaderRefreshing(); - }; - #endregion - } - /// <summary> - /// 鍔犺浇鏁版嵁鐨勬柟娉� - /// </summary> - public void Show() - { - middViewLayout.RemoveAll(); - UI2.FuntionControlView.Music.UpdateThread.playMusuc(middViewLayout, "USB", "USBDiskQueue",A31MusicModel.Current.USBList, A31MusicModel.Current); - } - /// <summary> - /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 - /// </summary> - public void UpdateSelectedMusic() - { - UI2.FuntionControlView.Music.UpdateThread.updateThread(this, middViewLayout, A31MusicModel.Current); - } - - } -} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs index 01c7106..2d2a565 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs @@ -3,19 +3,32 @@ using Shared; using Shared.IO; using System.Net; +using HDL_ON.Entity; +using HDL_ON.UI.UI2.FuntionControlView.Music; + namespace HDL_ON.UI.Music { public class MusicMain : FrameLayout { + private static MusicMain m_MusicMain = null; + public static MusicMain mMusicMain + { + get + { + if (m_MusicMain == null) + { + m_MusicMain = new MusicMain(); + } + return m_MusicMain; + } + } /// <summary> /// MusicMain瀵硅薄鏋勯�犲嚱鏁� /// </summary> public MusicMain() { Tag = "MusicMain"; - //杩涙潵闊充箰鍒楄〃鐣岄潰鍏堢Щ闄や箣鍓嶇嚎绋�; - A31MusicModel.RemoveListThread(); } /// <summary> /// 閲嶅啓RemoveFromParent鏂规硶 @@ -24,7 +37,8 @@ { base.RemoveFromParent(); clearA31Threads(); - A31MusicModel.ReadMusicStates();//杩涙潵娌℃湁闊充箰琚敹钘忚繃锛岄��鍑烘湁闊充箰琚敹钘忚繃 + //杩涙潵娌℃湁闊充箰琚敹钘忚繃锛岄��鍑烘湁闊充箰琚敹钘忚繃 + //A31MusicModel.ReadMusicStates(); } /// <summary> /// 鍒涘缓绾跨▼鍒楄〃 @@ -56,19 +70,22 @@ /// <summary> /// 鏄剧ず鍔犺浇鐣岄潰 /// </summary> - public static Loading loading = new Loading(); + public static Loading loading = new Loading(); /// <summary> /// 瀹氫箟鍏ㄥ眬瀵硅薄 /// </summary> VerticalRefreshLayout verticalRefresh; + /// <summary> + /// 涓轰簡闊充箰鍒锋柊鐘舵�佸畾涔夊叏灞�瀵硅薄 + /// </summary> + MusicView musicView = new MusicView(); public void Show() { - #region 鐣岄潰甯冨眬 this.BackgroundColor = MusicColor.ViewColor; var topView = new TopView(); this.AddChidren(topView.TopFLayoutView()); - topView.topNameBtn.TextID =StringId.a31Music; + topView.topNameBtn.TextID = StringId.a31Music; topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); @@ -78,214 +95,120 @@ { Y = topView.fLayout.Bottom, Height = Application.GetRealHeight(H_W.H - H_W.T_Height), + Name = "verticalRefresh", }; this.AddChidren(verticalRefresh); #endregion verticalRefresh.BeginHeaderRefreshingAction += () => { - SeachMusic(false); - + verticalRefresh.EndHeaderRefreshing(); + ////鍙戦�佽鍙栭煶涔愭挱鏀惧櫒鐘舵�佺嚎绋� + SeachMusic(); }; this.AddChidren(loading); + SeachMusic(); - if (A31MusicModel.A31MusicModelList.Count == 0) - { - SeachMusic(true); - } - else - { - clearA31Threads(); - //verticalRefresh.RemoveAll(); - for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) - { - var a31player = A31MusicModel.A31MusicModelList[i]; - ///杩欎釜鐘舵�佹槸涔嬪墠淇濆瓨鐨勶紝鍔犺浇瀹屾垚鍚庤鏍囪涓轰笉鍦ㄧ嚎锛屽悗闈㈠啀璇诲彇姝g‘鐨勭姸鎬� - if (!a31player.IsCanShow) - { - continue; - } - if (A31MusicModel.A31MusicModelList.Count - 1 == i) - { - a31player.IsEnd = true; - } - else - { - a31player.IsEnd = false; - } - ///鍔犺浇鐣岄潰鏃堕粯璁や笉鍦ㄧ嚎 - ///杩欓噷鏍囪鏄负浜嗕笉璇诲彇涓嶅湪绾挎挱鏀惧櫒鐘舵�� - a31player.IsOnLine = false; - MusicListView(a31player); - } - ///璇诲彇姝g‘鐨勪俊鎭紝鍖呮嫭IP鍜岀鍙e強鍚嶇О - SendMethod.Seach((obj) => - { - try - { - if (obj == null) - { - ///杩欓噷瑕佽鍙栦富浠庡叧绯� - readServerOrClientMode(); - A31MusicModel.Save(); - return; - } - var a31MusicModel = A31MusicModel.A31MusicModelList.Find((music) => music.UniqueDeviceName == obj.UniqueDeviceName); - if (a31MusicModel != null) - { - a31MusicModel.IPAddress = obj.IPAddress; - a31MusicModel.Port = obj.Port; - a31MusicModel.Name = obj.Name; - a31MusicModel.IsCanShow = true; - a31MusicModel.IsOnLine = true; - } - } - catch (Exception e) { MainPage.Log(e.Message); } - }); - } } /// <summary> /// 鍒锋柊鎾斁鍣ㄥ垪琛� /// </summary> - /// <param name="Yes">鏄惁鏄剧ず鍒锋柊鍥炬爣</param> - void SeachMusic(bool Yes = false) + void SeachMusic() { - for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) + + Application.RunOnMainThread(() => { - var a31player = A31MusicModel.A31MusicModelList[i]; - a31player.IsCanShow = false; - a31player.IsOnLine = false; - } - if (Yes) - { - //涓轰簡绗竴娆¤繘鏉og涓�涓�; - loading.Start(); - } - SendMethod.Seach((obj) => - { - if (obj == null) + verticalRefresh.RemoveAll(); + var musicListFunction = FunctionList.List.GetMusicList(); + for (int i = 0; i < musicListFunction.Count; i++) { - readServerOrClientMode(); - A31MusicModel.Save(); - if (!Yes) + var function = musicListFunction[i]; + var music = A31MusicModel.A31MusicModelList.Find((music) => + (music.functionMusic.deviceId == function.deviceId && function.spk == "music.standard") || ( + music.functionMusic.deviceId == function.deviceId && function.spk == "av.music") + ); + if (music == null) { - ///绛夊緟璺戝畬鍦ㄥ叧闂� - verticalRefresh.EndHeaderRefreshing(); + A31MusicModel.A31MusicModelList.Add(new A31MusicModel { functionMusic = function }); } + else + { + music.functionMusic = function; + } + } + + for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) + { + + var a31player = A31MusicModel.A31MusicModelList[i]; + if (a31player.functionMusic.online == false) + { + //涓嶅湪绾夸笉鏄剧ず + continue; + } + Application.RunOnMainThread(() => { - if (Yes) + MusicListView(a31player); + }); + } + ///杩涙潵璇讳竴娆¢煶涔愭挱鏀惧櫒鐘舵�� + for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) + { + + var a31player = A31MusicModel.A31MusicModelList[i]; + if (a31player.functionMusic.online == false) + { + //涓嶅湪绾夸笉璇诲彇 + continue; + } + //鍙戦�佽鍙栭煶涔愭挱鏀惧櫒鐘舵�佺嚎绋� + System.Threading.Tasks.Task.Run(() => + { + try { - //涓轰簡绗竴娆¤繘鏉og涓�涓�; - loading.Hide(); + SendMethod.mMethod.RefreshDeviceStatus(new List<string> { a31player.functionMusic.deviceId }); + System.Threading.Thread.Sleep(500); } - verticalRefresh.RemoveAll(); - for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) - { - var a31player = A31MusicModel.A31MusicModelList[i]; - //杩欎釜鐘舵�佹槸涔嬪墠淇濆瓨鐨勶紝鍔犺浇瀹屾垚鍚庤鏍囪涓轰笉鍦ㄧ嚎锛屽悗闈㈠啀璇诲彇姝g‘鐨勭姸鎬� - if (!a31player.IsCanShow) - { - continue; - } - if (A31MusicModel.A31MusicModelList.Count - 1 == i) - { - a31player.IsEnd = true; - } - else - { - a31player.IsEnd = false; - } - MusicListView(a31player); - } - //A31MusicModel.ReadMusicStates(); + catch { } }); - return; } - var a31MusicModel = A31MusicModel.A31MusicModelList.Find((music) => { return music.UniqueDeviceName == obj.UniqueDeviceName; }); - if (a31MusicModel == null) - { - //涓嶆槸鎴戜滑鏀寔鐨勫搧鐗屼笉鏀寔 - if (obj.Name != null) - { - obj.sid = "030101123456780909020123AABB" + obj.UniqueDeviceName; - A31MusicModel.A31MusicModelList.Add(obj); - } - } - else - { - a31MusicModel.IPAddress = obj.IPAddress; - a31MusicModel.Port = obj.Port; - a31MusicModel.Name = obj.Name; - a31MusicModel.IsCanShow = true; - a31MusicModel.IsOnLine = true; - } + }); } /// <summary> /// 鏄剧ず闊充箰鍒楄〃鐨勬柟娉� /// </summary> - void MusicListView(A31MusicModel a31player) + void MusicListView(A31MusicModel player) { - MusicView musicView = new MusicView(); - musicView.View(verticalRefresh); - musicView.singerBtn.Text = a31player.A31PlayStatus.Artist; - musicView.songNameBtn.Text = a31player.A31PlayStatus.Title; - musicView.musicNameBtn.Text = new View.DialogView { }.NamePlayer(a31player); - if (a31player.IsEnd) - { - musicView.muiscFl.Height = Application.GetRealHeight(12 + 139 + 12); - } + musicView.ViewAddChidren(verticalRefresh); + musicView.muiscFl.Tag = player.functionMusic;//澶氫釜闊充箰鎾斁鍣ㄦ洿鏂扮姸鎬佽鐢ㄥ埌 + musicView.singerBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name); + musicView.songNameBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name); + musicView.musicNameBtn.Text = player.functionMusic.name; + ///鏀惰棌浜嬩欢 musicView.collectIconBtn.MouseUpEventHandler += (sender, e) => { musicView.collectIconBtn.IsSelected = !musicView.collectIconBtn.IsSelected; - if (a31player.ServerClientType == 1) + if (musicView.collectIconBtn.IsSelected) { - if (musicView.collectIconBtn.IsSelected) - { - a31player.MainPlayCollection = true; - } - else - { - a31player.MainPlayCollection = false; - } + player.functionMusic.collect = true; } else { - if (musicView.collectIconBtn.IsSelected) - { - a31player.collect = true; - } - else - { - a31player.collect = false; - } - } - A31MusicModel.Save(); - }; - - EventHandler<MouseEventArgs> clickMergence = (sender, e) => - { - if (a31player.ServerClientType == 0) - { - new View.DialogView { }.PlayMergence(a31player); - } - else if (a31player.ServerClientType == 1) - { - new View.DialogView { }.DetachPlayMergence(a31player); - + player.functionMusic.collect = false; } }; - musicView.mergeBjBtn.MouseUpEventHandler += clickMergence; - musicView.mergeBtn.MouseUpEventHandler += clickMergence; - musicView.mergeIconBtn.MouseUpEventHandler += clickMergence; + + ///杩涘叆闊充箰涓婚〉浜嬩欢 EventHandler<MouseEventArgs> clickPlayView = (sender, e) => { - A31MusicModel.Current = a31player;//褰撳墠鎾斁鍣� + + A31MusicModel.Current = player; var a31PlayMusicPage = new A31PlayMusicPage(); MainPage.BasePageView.AddChidren(a31PlayMusicPage); a31PlayMusicPage.Show(); @@ -302,7 +225,10 @@ musicView.prevBtn.MouseDownEventHandler += (sender, e) => { musicView.prevBtn.IsSelected = true; - SendMethod.Previous(a31player); + player.functionMusic.SetAttrState(KeyProperty.song_step, ValueProperty.up); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add(KeyProperty.song_step, ValueProperty.up); + SendMethod.mMethod.SendControlCommand(player.functionMusic, dic); }; musicView.prevBtn.MouseUpEventHandler += (sender, e) => { @@ -311,46 +237,54 @@ ///鏆傚仠/鎾斁鐐瑰嚮浜嬩欢 musicView.playBtn.MouseDownEventHandler += (sender, e) => { + string status = ValueProperty.off; if (musicView.playBtn.IsSelected) { musicView.playBtn.IsSelected = false; - SendMethod.Pause(a31player); - a31player.A31PlayStatus.status = "pause"; + status = ValueProperty.off; } else { musicView.playBtn.IsSelected = true; - SendMethod.Play(a31player); - a31player.A31PlayStatus.status = "play"; + status = ValueProperty.on; } + player.functionMusic.SetAttrState(KeyProperty.on_off, status); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add(KeyProperty.on_off, status); + SendMethod.mMethod.SendControlCommand(player.functionMusic, dic); }; ///涓嬩竴鏇茬偣鍑讳簨浠� musicView.nextBtn.MouseDownEventHandler += (sender, e) => { musicView.nextBtn.IsSelected = true; - SendMethod.Next(a31player); + player.functionMusic.SetAttrState(KeyProperty.song_step, ValueProperty.down); + Dictionary<string, string> dic = new Dictionary<string, string>(); + dic.Add(KeyProperty.song_step, ValueProperty.down); + SendMethod.mMethod.SendControlCommand(player.functionMusic, dic); }; musicView.nextBtn.MouseUpEventHandler += (sender, e) => { musicView.nextBtn.IsSelected = false; }; - + //鏇存柊鐘舵�佺嚎绋� var musicThread = new System.Threading.Thread(() => { while (true) { - System.Threading.Thread.Sleep(1000); - if (!a31player.IsOnLine) + if (!player.functionMusic.online) { + ///涓嶅湪绾夸笉璇荤姸鎬� continue; } - SendMethod.ReadStatus(a31player); + //SendMethod.ReadStatus(player); + SendMethod.mMethod.GetDeviceStatus(ref player, new List<string> { player.functionMusic.deviceId }, player.functionMusic.sid); + System.Threading.Thread.Sleep(1000); Application.RunOnMainThread(() => { - musicView.singerBtn.Text = a31player.A31PlayStatus.Artist; - musicView.songNameBtn.Text = a31player.A31PlayStatus.Title; - musicView.musicNameBtn.Text = new View.DialogView { }.NamePlayer(a31player); - if (a31player.A31PlayStatus.status == "play") + musicView.singerBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name); + musicView.songNameBtn.Text = player.functionMusic.GetAttrState(KeyProperty.song_name); + musicView.musicNameBtn.Text = player.functionMusic.name; + if (player.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on) { musicView.playBtn.IsSelected = true; } @@ -358,28 +292,15 @@ { musicView.playBtn.IsSelected = false; } - musicView.regionBtn.Text = a31player.GetRoomListName(); - if (a31player.ServerClientType == 1) + musicView.regionBtn.Text = player.functionMusic.GetRoomListName(); + + if (player.functionMusic.collect) { - if (a31player.MainPlayCollection) - { - musicView.collectIconBtn.IsSelected = true; - } - else - { - musicView.collectIconBtn.IsSelected = false; - } + musicView.collectIconBtn.IsSelected = true; } else { - if (a31player.collect) - { - musicView.collectIconBtn.IsSelected = true; - } - else - { - musicView.collectIconBtn.IsSelected = false; - } + musicView.collectIconBtn.IsSelected = false; } }); } @@ -388,99 +309,121 @@ musicThread.Start(); threadLists.Add(musicThread); } + /// <summary> - /// 璇诲彇涓讳粠鍏崇郴 + ///鎸囧畾鍒锋柊鐣岄潰 /// </summary> - void readServerOrClientMode() + /// <param name="strView">鍒ゆ柇瀛楃</param> + public void RefreshView(AlinkStatusData alinkStatusData) { - try + if (alinkStatusData == null || alinkStatusData.status.Count == 0) { - for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) + return; + } + Application.RunOnMainThread(() => + { + try { - var a31player = A31MusicModel.A31MusicModelList[i]; - if (!a31player.IsOnLine) + for (int a =0; a < MainPage.BasePageView.ChildrenCount; a++) { - continue; - } - try - { - a31player.ServerClientType = 0; - var result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); - if (result == null && result == "Failed") + var view = MainPage.BasePageView.GetChildren(a); + if (view.GetType() == typeof(MusicMain)) { - result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); - } - if (result != null && result != "Failed") - { - a31player.Slave = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result); - } - } - catch (Exception e) - { - var d = e.Message; - } - } - - //鍒嗘瀽涓讳粠鍏崇郴 - for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) - { - var a31player = A31MusicModel.A31MusicModelList[i]; - if (!a31player.IsOnLine) - { - continue; - } - try - { - if (a31player.Slave != null && "0" != a31player.Slave.slaves) - { - a31player.ServerClientType = 1;//涓荤殑 - string str = a31player.Name; - for (int j = 0; j < a31player.Slave.slave_list.Count; j++) + var musicMain = view as MusicMain; + if (musicMain != null) { - - var slave = a31player.Slave.slave_list[j]; - str = str + "+" + slave.name; - var tempA31Player = A31MusicModel.A31MusicModelList.Find((obj) => slave.uuid.Replace("uuid:", "") == obj.UniqueDeviceName); - if (tempA31Player == null) + for (int b = 0; b < musicMain.ChildrenCount; b++) { - A31MusicModel.A31MusicModelList.Add(new A31MusicModel + var view1 = musicMain.GetChildren(b); + if (view1.GetType() == typeof(VerticalRefreshLayout)) { - sid = "030101123456780909020123AABB" + slave.uuid.Replace("uuid:", ""), - ServerClientType = -1,//浠庣殑 - IPAddress = slave.ip, - MainPlayIP = a31player.IPAddress, - UniqueDeviceName = slave.uuid.Replace("uuid:", ""), - Name = slave.name, - IsCanShow = false, - IsOnLine = false,//true浣滅敤涓轰簡璇诲彇浠庢挱鏀惧櫒鐨勯煶閲� - }); - } - //濡傛灉鎵惧埌灏辨洿鏂颁负浠庣殑 - else - { - tempA31Player.ServerClientType = -1;//浠庣殑 - tempA31Player.IPAddress = slave.ip; - tempA31Player.MainPlayIP = a31player.IPAddress; - tempA31Player.Name = slave.name; - tempA31Player.UniqueDeviceName = slave.uuid.Replace("uuid:", ""); - tempA31Player.IsCanShow = false; - tempA31Player.IsOnLine = false;//true浣滅敤涓轰簡璇诲彇浠庢挱鏀惧櫒鐨勯煶閲� + var vv = view1 as VerticalRefreshLayout; + if (vv != null && vv.Name == "verticalRefresh") + { + for (int c = 0; c < vv.ChildrenCount; c++) + { + var viewfl = vv.GetChildren(c); + if (viewfl.GetType() == typeof(FrameLayout)) + { + var fl = viewfl as FrameLayout; + if ((fl.Tag as Function).sid!= alinkStatusData.sid) { + //涓嶆槸褰撳墠闊充箰涓嶄細鏇存柊鐘舵�� + continue; + } + if (fl != null && fl.Name == "parentfl") + { + for (int i = 0; i < fl.ChildrenCount; i++) + { + var viewfl1 = fl.GetChildren(i); + if (viewfl1.GetType() == typeof(FrameLayout)) + { + var fl1 = viewfl1 as FrameLayout; + if (fl1 != null && fl1.Name == "musicparentfl") + { + for (int j = 0; j < fl1.ChildrenCount; j++) + { + + if (fl1.GetChildren(j).GetType() == typeof(Button)) + { + var btn = fl1.GetChildren(j) as Button; + if (btn == null ||btn.Name==null) + { + continue; + } + switch (btn.Name) + { + case "song": + { + var s = alinkStatusData.status.Find((o) => o.key == KeyProperty.song_name); + if (s != null) + { + btn.Text = s.value; + } + } + break; + case "playstatus": + { + + var s = alinkStatusData.status.Find((o) => o.key == KeyProperty.on_off); + if (s != null) + { + if (s.value == ValueProperty.on) + { + btn.IsSelected = true; + } + else + { + btn.IsSelected = false; + } + } + } + break; + } + + } + } + } + } + + } + } + } + + } + } + + } } } - a31player.MainPlayName = str; + } } - catch (Exception e) - { - var ss = e.Message; - } + } - - } - catch { } + catch { } + }); } - } } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/MusicProperty.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/MusicProperty.cs new file mode 100644 index 0000000..22bd45a --- /dev/null +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/MusicProperty.cs @@ -0,0 +1,141 @@ +锘縰sing System; +using HDL_ON.Entity; + +namespace HDL_ON.UI.UI2.FuntionControlView.Music +{ + public class KeyProperty + { + private static KeyProperty sMusicPropertyKey = null; + + public static KeyProperty sMusicProperty + { + get + { + if (sMusicPropertyKey == null) + { + sMusicPropertyKey = new KeyProperty(); + } + return sMusicPropertyKey; + } + } + + #region ---灞炴��---- + + /// <summary> + /// 寮�鍏�<on/off> + /// </summary> + public const string on_off = "on_off"; + /// <summary> + /// 闊抽噺<0-100> + /// </summary> + public const string volume = "volume"; + /// <summary> + /// 妯″紡<single/single_cycle/order/list_cycle/random> + /// </summary> + public const string mode = "mode"; + /// <summary> + /// 闊虫簮<sdcard/audio_in/ftp/radio/bluetooth> + /// </summary> + public const string source = "source"; + /// <summary> + /// 鍒楄〃鍚� + /// </summary> + public const string playlist_name = "playlist_name"; + /// <summary> + /// 姝屾洸鍚� + /// </summary> + public const string song_name = "song_name"; + /// <summary> + /// 鍒囨瓕<up/down> + /// </summary> + public const string song_step = "song_step"; + /// <summary> + /// 褰撳墠姝屾洸鎬绘椂闂�<0-9999(s)> + /// </summary> + public const string song_time = "song_time"; + /// <summary> + /// 褰撳墠姝屾洸鎾斁鏃堕棿<0-9999(s)> + /// </summary> + public const string playing_time = "playing_time"; + + + #endregion + + + + /// <summary> + /// 鑾峰彇on_off鍊� + /// </summary> + /// <param name="function">褰撳墠闊充箰</param> + /// <returns></returns> + public string GetOnOffKeyValue(Function function) + { + if (function == null) + { + return ""; + } + return function.GetAttrState(on_off); + + } + /// <summary> + /// 璁剧疆on_off鍊� + /// </summary> + /// <param name="function">褰撳墠闊充箰</param> + /// <returns></returns> + public void SetOnOffKeyValue(Function function, string stateValue) + { + if (function == null) + { + return; + } + function.SetAttrState(on_off, stateValue); + + } + + } + public class ValueProperty + { + #region ---灞炴�у��---- + /// <summary> + /// <up> + /// </summary> + public const string up = "up"; + /// <summary> + /// <down> + /// </summary> + public const string down = "down"; + /// <summary> + /// 寮�<on> + /// </summary> + public const string on = "on"; + /// <summary> + /// 鍏�<off> + /// </summary> + public const string off = "off"; + /// <summary> + /// 鍗曟洸<single> + /// </summary> + public const string single = "single"; + /// <summary> + /// 鍗曟洸寰幆 + /// </summary> + public const string single_cycle = "single_cycle"; + /// <summary> + /// 寰簭寰幆 + /// </summary> + public const string order = "order"; + /// <summary> + /// 鍒楄〃寰幆 + /// </summary> + public const string list_cycle = "list_cycle"; + /// <summary> + /// 闅忔満鎾斁 + /// </summary> + public const string random = "random"; + + #endregion + + + + } +} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs index dd36144..70026c6 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs @@ -4,883 +4,155 @@ using System.Net.Sockets; using System.Security; using System.Text; +using HDL_ON.DAL.Server; +using HDL_ON.Entity; using Shared; namespace HDL_ON.UI.Music { public class SendMethod { - /// <summary> - ///鎼滅储A31闊充箰鎾斁鍣� - /// </summary> - /// <param name="action"></param> - /// <param name="time"></param> - /// <param name="uid"></param> - public static void Seach(Action<A31MusicModel> action, int time = 5 * 1000, string uid = "AllUniqueDeviceName") + private static SendMethod sMethod=null; + public static SendMethod mMethod { - System.Threading.Tasks.Task.Run(() => + get { - System.Net.Sockets.UdpClient udpClient = null; - int localPort = 65535; - for (; 1024 < localPort; localPort--) + if (sMethod == null) { - try - { - udpClient = new System.Net.Sockets.UdpClient(localPort); - break; - } - catch (Exception e) { System.Console.WriteLine(e.Message); } + sMethod = new SendMethod(); } + return sMethod; + } - System.Threading.Tasks.Task.Run(() => - { - var tempDateTime = DateTime.Now; - while (udpClient != null) - { - try - { - if (time < (DateTime.Now - tempDateTime).TotalMilliseconds) - { - var tempBytes = System.Text.Encoding.UTF8.GetBytes("瀹屾垚"); - udpClient.Send(tempBytes, tempBytes.Length, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), localPort)); - } - else - { - var stringBuilder = new StringBuilder(); - stringBuilder.AppendLine("M-SEARCH * HTTP/1.1"); - stringBuilder.AppendLine("St: ssdp:wiimudevice"); - stringBuilder.AppendLine("Mx: 3"); - stringBuilder.AppendLine("Host: 239.255.255.250:1900"); - stringBuilder.AppendLine("Man: \"ssdp:discover\""); - stringBuilder.AppendLine(); - var tempBytes = System.Text.Encoding.ASCII.GetBytes(stringBuilder.ToString()); - //璇锋眰鑾峰彇A31鏈嶅姟鍣ㄤ俊鎭� - udpClient.Send(tempBytes, tempBytes.Length, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("239.255.255.250"), 1900)); - udpClient.Send(tempBytes, tempBytes.Length, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("239.255.255.250"), 1900)); - //濡傛灉1000姣娌℃湁鏁版嵁鍥炲锛屽氨鍏抽棴褰撳墠Socket锛屼笉鍐嶇瓑寰呮帴鏀舵暟鎹� - } - System.Threading.Thread.Sleep(500); - } - catch (Exception e) { System.Console.WriteLine(e.Message); } - } - }); - while (true) - { - try - { - //鎺ユ敹鍥炴潵鐨勬暟鎹� - var remoteIpEndPoint = new System.Net.IPEndPoint(0, 0); - //寮�濮嬪湪杩欓噷绛夊緟鎺ユ敹鏁版嵁锛� - var receviceBytes = udpClient.Receive(ref remoteIpEndPoint); - if (receviceBytes == null) - { - break; - } - if ("瀹屾垚" == System.Text.Encoding.UTF8.GetString(receviceBytes)) - { - if (action != null) - { - //琛ㄧず瀹屾垚浜� - action(null); - } - try - { - udpClient.Close(); - udpClient = null; - } - catch (Exception e) { System.Console.WriteLine(e.Message); } - break; - } - - var sr = new System.IO.StreamReader(new System.IO.MemoryStream(receviceBytes, 0, receviceBytes.Length)); - string tempLine = null; - string ipAddress = null; - int port = 0; - string uniqueDeviceName = null; - //涓�琛屼竴琛屾暟鎹垽鏂紝鎵惧嚭闇�瑕佺殑淇℃伅 - while ((tempLine = sr.ReadLine()) != null) - { - //鎵惧嚭Ip鍦板潃鐩稿叧鐨勪俊鎭� - //System.Console.WriteLine (tempLine); - if (tempLine.StartsWith("LOCATION: http://")) - { - tempLine = tempLine.Replace("LOCATION: http://", "").Split('/')[0]; - string[] ipAndPort = tempLine.Split(':'); - ipAddress = ipAndPort[0]; - port = int.Parse(ipAndPort[1]); - } - else if (tempLine.StartsWith("USN: uuid:")) - { - uniqueDeviceName = tempLine.Replace("USN: uuid:", "").Split(':')[0]; - } - } - //鍏抽棴娴� - sr.Close(); - - if (action != null) - { - if ("AllUniqueDeviceName" == uid) - { - action(new A31MusicModel { IPAddress = ipAddress, Port = port, Name = GetDeviceName(ipAddress, port), UniqueDeviceName = uniqueDeviceName }); - } - else if (uid == uniqueDeviceName) - { - if (action != null) - { - //琛ㄧず瀹屾垚浜� - action(null); - } - try - { - udpClient.Close(); - udpClient = null; - } - catch (Exception e) { System.Console.WriteLine(e.Message); } - break; - } - } - } - catch (Exception e) { System.Console.WriteLine(e.Message); } - } - }); } /// <summary> - /// 鏇存柊A31鎾斁鍣ㄧ殑鐘舵�� + /// 鑾峰彇闊充箰鍒楄〃 /// </summary> - /// <param name="a31MusicModel"></param> - public static void ReadStatus(A31MusicModel a31MusicModel) + public List<Function> GetMusicList + { + get + { + return FunctionList.List.GetMusicList(); + } + } + /// <summary> + /// 鍙戦�佹帶鍒跺懡浠� + /// </summary> + /// <param name="function">褰撳墠璁惧</param> + /// <param name="dic">鍙戦�佹帶鍒舵暟鎹�</param> + public void SendControlCommand(Function function, Dictionary<string, string> dic) + { + new System.Threading.Thread(() => + { + DriverLayer.Control.Ins.SendWriteCommand(function, dic); + }) + { IsBackground = true }.Start(); + } + + /// <summary> + /// 鑾峰彇璁惧鏈�鏂扮殑鐘舵�� + /// </summary> + /// <returns></returns> + public void GetDeviceStatus(ref A31MusicModel a31Music, List<string> functionIds, string sid) { try { - if (a31MusicModel.ServerClientType == 1) - { - var result = OpenWeb("http://" + a31MusicModel.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); - if (result != null && result != "Failed") - { - var slaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result); - if (slaves != null && slaves.slave_list != null && slaves.slave_list.Count != 0) - { - a31MusicModel.Slave = slaves; - } - } - } - - WebClient webClient = new WebClient(); - webClient.Headers.Add("Soapaction", "\"urn:schemas-upnp-org:service:AVTransport:1#GetInfoEx\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - - var recevieBytes = webClient.UploadData(new Uri("http://" + a31MusicModel.IPAddress + ":" + a31MusicModel.Port + "/upnp/control/rendertransport1"), "POST", System.Text.Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><u:GetInfoEx xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetInfoEx></s:Body></s:Envelope>")); - a31MusicModel.LastDateTime = DateTime.Now;//璁板綍鏁版嵁鍙嶉鐨勬椂闂�(鍥犱负鏈夋椂闂寸綉缁滃樊鏁版嵁涓嶅洖澶嶏紝瀵艰嚧褰撳墠鎾斁闊充箰鏃堕棿鏄剧ず涓嶆纭�) - - var se = System.Security.SecurityElement.FromString(System.Text.Encoding.UTF8.GetString(recevieBytes)).SearchForChildByTag("s:Body").SearchForChildByTag("u:GetInfoExResponse"); - - if ("PLAYING" == se.SearchForTextOfTag("CurrentTransportState")) - { - a31MusicModel.A31PlayStatus.status = "play"; - } - else - { - a31MusicModel.A31PlayStatus.status = "stop"; - } - a31MusicModel.A31PlayStatus.totlen = (DateTime.Parse(se.SearchForTextOfTag("TrackDuration")) - DateTime.Parse("00:00:00")).TotalMilliseconds.ToString(); - - var trackMetaData = se.SearchForTextOfTag("TrackMetaData"); - if (string.IsNullOrEmpty(trackMetaData)) + // RefreshDeviceStatus(functionIds); + a31Music.LastDateTime = DateTime.Now; + ///浠庣紦瀛橀噷闈㈡煡鎵鹃煶涔愭挱鏀惧櫒瀵硅薄<缂撳瓨鏁版嵁鏀跺埌鎺ㄩ�佽繃鏉ョ殑鐘舵�佷細鏇存柊缂撳瓨鏁版嵁> + var allLocalFuntion = FunctionList.List.GetDeviceFunctionList(); + var localFunction = allLocalFuntion.Find((obj) => obj.sid == sid); + if (localFunction == null) { return; } - if (A31MusicModel.IsJson(trackMetaData)) - { - var a31QQSong = Newtonsoft.Json.JsonConvert.DeserializeObject<A31QQSong>(trackMetaData); - a31MusicModel.A31PlayStatus.Title = a31QQSong.title; - a31MusicModel.A31PlayStatus.Album = a31QQSong.album; - a31MusicModel.A31PlayStatus.Artist = a31QQSong.creator; - } - else - { - var metadata = trackMetaData.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "").Replace("&", "&amp;"); - var item = SecurityElement.FromString(metadata).SearchForChildByTag("item"); - a31MusicModel.A31PlayStatus.Title = item.SearchForTextOfTag("dc:title"); - a31MusicModel.A31PlayStatus.Artist = item.SearchForTextOfTag("upnp:artist"); - a31MusicModel.A31PlayStatus.Album = item.SearchForTextOfTag("upnp:album"); - } - a31MusicModel.A31PlayStatus.curpos = (DateTime.Parse(se.SearchForTextOfTag("RelTime")) - DateTime.Parse("00:00:00")).TotalMilliseconds.ToString(); - a31MusicModel.A31PlayStatus.vol = se.SearchForTextOfTag("CurrentVolume"); - a31MusicModel.A31PlayStatus.loop = se.SearchForTextOfTag("LoopMode"); - a31MusicModel.A31PlayStatus.Source = se.SearchForTextOfTag("PlayMedium"); - a31MusicModel.A31PlayStatus.playSource = se.SearchForTextOfTag("TrackSource"); - a31MusicModel.A31PlayStatus.TrackURL = se.SearchForTextOfTag("TrackURI").Replace("&", "&amp;"); + ///鏇存柊鐨勬暟鎹� + a31Music.functionMusic = localFunction; } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } - finally - { - #region 鏇存柊鍏朵粬鐣岄潰闊充箰鐘舵�� - Application.RunOnMainThread(() => - { - a31MusicModel.trait_on_off.curValue = a31MusicModel.A31PlayStatus.status == "play" ? "on" : "off"; - //Console.WriteLine($"music : {a31MusicModel.sid} : {a31MusicModel.on_off}"); - HomePage.UpdataFunctionStates(a31MusicModel); - foreach (var e in A31MusicModel.A31MusicModelList) - { - RoomPage.UpdataStates(a31MusicModel); - } - }); - #endregion - } + catch { } } - public static string OpenWeb(string url) - { - try - { - var webClient = new WebClient(); - return webClient.DownloadString(url); - } - catch (Exception e) - { - System.Console.WriteLine(e.Message); - return null; - } - } /// <summary> - /// 鑾峰彇A31鐨勫悕绉� + /// 鍒锋柊璁惧鐘舵�� /// </summary> - /// <param name="ip"></param> - /// <param name="port"></param> /// <returns></returns> - static string GetDeviceName(string ip, int port) + public void RefreshDeviceStatus(List<string> functionIds) { - string deviceName = null; - System.IO.StreamReader sr = null; - WebClient webClient = new WebClient(); try { - var receviceBytes = webClient.DownloadData(new Uri("http://" + ip + ":" + port + "/description.xml")); - sr = new System.IO.StreamReader(new System.IO.MemoryStream(receviceBytes), Encoding.UTF8); - string line = null; - string deviceType = null; - - while ((line = sr.ReadLine()) != null) + Dictionary<string, object> d = new Dictionary<string, object>(); + d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); + d.Add("deviceIds", functionIds); + var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_RefreshDeviceStatus); + if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") { - //System.Console.WriteLine (line); - if (line.StartsWith("<friendlyName>")) - { - deviceName = line.Replace("<friendlyName>", "").Replace("</friendlyName>", ""); - } - else if (line.StartsWith("<manufacturer>")) - { - deviceType = line.Replace("<manufacturer>", "").Replace("</manufacturer>", ""); - } + return; } - switch (deviceType) - { - case "iEAST": - case "Linkplay Technology Inc.": - break; - //涓嶆槸A31鐨勯煶涔愭暟鎹� - default: - deviceName = null; - break; - } - - } - catch (Exception e) - { - System.Console.WriteLine(e.Message); - } - finally - { - if (sr != null) - { - sr.Close(); - } - } - return deviceName; - } - - /// <summary> - /// 鍒囨崲鎾斁鍣ㄦā寮�,淇敼闊充箰鍚嶇О,鍒囨崲钃濈墮,绾胯矾杈撳叆 - /// </summary> - /// <param name="coutn"></param> - public static void SendCommand(string url) - { - System.Threading.Tasks.Task.Run(() => - { - WebClient webClient = new WebClient(); - try - { - byte[] recevieBytes1 = webClient.DownloadData(new Uri(url)); - } - catch (Exception ex) - { - //this.IPAddress = ex.Message; - } - }); - } - /// <summary> - /// 鎾斁 - /// </summary> - public static void Play(A31MusicModel a31player) - { - System.Threading.Tasks.Task.Run(() => - { - StringBuilder sb = new StringBuilder(); - sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - sb.AppendLine("<s:Body>"); - sb.AppendLine("<u:Play xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">"); - sb.AppendLine("<InstanceID>0</InstanceID>"); - sb.AppendLine("<Speed>1</Speed>"); - sb.AppendLine("</u:Play>"); - sb.AppendLine("</s:Body>"); - sb.AppendLine("</s:Envelope>"); - - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:AVTransport:1#Play\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendertransport1"), "POST", Encoding.UTF8.GetBytes(sb.ToString())); - } - catch { } - }); - } - /// <summary> - /// 鏆傚仠 - /// </summary> - public static void Pause(A31MusicModel a31player) - { - System.Threading.Tasks.Task.Run(() => - { - StringBuilder sb = new StringBuilder(); - sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - sb.AppendLine("<s:Body>"); - sb.AppendLine("<u:Pause xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">"); - sb.AppendLine("<InstanceID>0</InstanceID>"); - sb.AppendLine("</u:Pause>"); - sb.AppendLine("</s:Body>"); - sb.AppendLine("</s:Envelope>"); - - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:AVTransport:1#Pause\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendertransport1"), "POST", Encoding.UTF8.GetBytes(sb.ToString())); - } - catch { } - }); - - } - /// <summary> - /// 涓嬩竴鏇� - /// </summary> - public static void Next(A31MusicModel a31player) - { - System.Threading.Tasks.Task.Run(() => - { - StringBuilder sb = new StringBuilder(); - sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - sb.AppendLine("<s:Body>"); - sb.AppendLine("<u:Next xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">"); - sb.AppendLine("<InstanceID>0</InstanceID>"); - sb.AppendLine("</u:Next>"); - sb.AppendLine("</s:Body>"); - sb.AppendLine("</s:Envelope>"); - - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:AVTransport:1#Next\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendertransport1"), "POST", Encoding.UTF8.GetBytes(sb.ToString())); - } - catch { } - }); - - } - /// <summary> - /// 涓婁竴鏇� - /// </summary> - public static void Previous(A31MusicModel a31player) - { - System.Threading.Tasks.Task.Run(() => - { - StringBuilder sb = new StringBuilder(); - sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - sb.AppendLine("<s:Body>"); - sb.AppendLine(" <u:Previous xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">"); - sb.AppendLine("<InstanceID>0</InstanceID>"); - sb.AppendLine("</u:Previous>"); - sb.AppendLine("</s:Body>"); - sb.AppendLine("</s:Envelope>"); - - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:AVTransport:1#Previous\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendertransport1"), "POST", Encoding.UTF8.GetBytes(sb.ToString())); - } - catch { } - }); - - } - /// <summary> - /// 蹇繘 - /// </summary> - public static void Seek(string seekvolume, A31MusicModel a31player) - { - System.Threading.Tasks.Task.Run(() => - { - StringBuilder sb = new StringBuilder(); - sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - sb.AppendLine("<s:Body>"); - sb.AppendLine(" <u:Seek xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">"); - sb.AppendLine("<InstanceID>0</InstanceID>"); - sb.AppendLine("<Unit>REL_TIME</Unit>"); - sb.AppendLine("<Target>" + seekvolume + "</Target>"); - sb.AppendLine("</u:Seek>"); - sb.AppendLine("</s:Body>"); - sb.AppendLine("</s:Envelope>"); - - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:AVTransport:1#Seek\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendertransport1"), "POST", Encoding.UTF8.GetBytes(sb.ToString())); - } - catch { } - }); - } - /// <summary> - /// 璋冭妭闊抽噺 - /// </summary> - /// <param name="volume">Volume.</param> - public static void ControlVolume(int volume, A31MusicModel a31player) - { - System.Threading.Tasks.Task.Run(() => { - A31MusicModel.ProgressDateTime = DateTime.Now; - try - { - if (a31player.ServerClientType == -1) - { - new System.Net.WebClient().DownloadData(new Uri("http://" + a31player.MainPlayIP + "/httpapi.asp?command=multiroom:SlaveVolume:" + a31player.IPAddress + ":" + volume)); - } - else if (a31player.ServerClientType == 1) - { - new System.Net.WebClient().DownloadData(new Uri("http://" + a31player.IPAddress + "/httpapi.asp?command=setPlayerCmd:slave_vol:" + volume)); - } - else - { - var sb = new StringBuilder(); - sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - sb.AppendLine("<s:Body>"); - sb.AppendLine("<u:SetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\">"); - sb.AppendLine("<InstanceID>0</InstanceID>"); - sb.AppendLine("<Channel>Master</Channel>"); - sb.AppendLine("<DesiredVolume>" + volume + "</DesiredVolume>"); - sb.AppendLine("</u:SetVolume>"); - sb.AppendLine("</s:Body>"); - sb.AppendLine("</s:Envelope>"); - - var webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-upnp-org:service:RenderingControl:1#SetVolume\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/rendercontrol1"), "POST", Encoding.UTF8.GetBytes(sb.ToString())); - } - } - catch { } - }); - - } - /// <summary> - /// 鑾峰彇USb鐨勫垪琛� - /// </summary> - public static List<MusicInfo> GetUsbList(A31MusicModel a31player) - { - var musicInfoList = new List<MusicInfo>(); - musicInfoList.Clear(); - var usbString = GetUSBPlayList(a31player); - if (usbString == null) - { - return musicInfoList; - } - var se = System.Security.SecurityElement.FromString(usbString); - if (se == null) - { - return musicInfoList; - } - while (se.Children != null) - { - se = se.Children[0] as System.Security.SecurityElement; - } - - 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").Replace("&", "&"); - var item = SecurityElement.FromString(metadata).SearchForChildByTag("item"); - musicInfo.Title = item.SearchForTextOfTag("dc:title").Replace("&", "&amp;"); - musicInfo.Artist = item.SearchForTextOfTag("upnp:artist").Replace("&", "&amp;"); - musicInfo.Album = item.SearchForTextOfTag("upnp:album").Replace("&", "&amp;"); - musicInfo.Duration = item.SearchForTextOfTag("res"); - musicInfo.AlbumId = item.SearchForTextOfTag("song:albumid").Replace("&", "&amp;"); - musicInfoList.Add(musicInfo); - } - return musicInfoList; - } - /// <summary> - ///璇锋眰USB鍒楄〃鍛戒护 - /// </summary> - public static string GetUSBPlayList(A31MusicModel a31player) - { - - StringBuilder getPlayList = new StringBuilder(); - getPlayList.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - getPlayList.AppendLine("<s:Body>"); - getPlayList.AppendLine("<u:BrowseQueue xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">"); - getPlayList.AppendLine("<QueueName>USBDiskQueue</QueueName>"); - getPlayList.AppendLine("</u:BrowseQueue>"); - getPlayList.AppendLine("</s:Body>"); - getPlayList.AppendLine("</s:Envelope>"); - - WebClient webClient = new WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#BrowseQueue\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - - try - { - byte[] recevieBytes = webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(getPlayList.ToString())); - return System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); - } - catch { } - - return null; - } - - /// <summary> - /// 璇诲彇鐢靛彴缁勫垪琛� - /// </summary> - /// <returns>璇诲彇鍒扮殑鐢靛彴缁勫垪琛ㄤ俊鎭紝璇诲彇涓嶅埌鍙嶉涓簄ull</returns> - public static string ReadRadioList(string url) - { - WebClient webClient = new WebClient(); - webClient.Proxy = null; - webClient.Headers.Add("Content-type", "plain/text; charset=UTF-8"); - if (Language.CurrentLanguage == "Chinese") - { - webClient.Headers.Add("Accept-Language", "zh-cn"); - } - else - { - webClient.Headers.Add("Accept-Language", "en-us"); - } - try - { - byte[] recevieBytes = webClient.DownloadData(new Uri(url)); - return System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); - - } - catch (Exception e) - { - return null; - } - - } - - /// <summary> - /// 鑾峰彇褰撳墠鎾斁鐨勫垪琛� - /// </summary> - public static string GetCurrentPlayList(A31MusicModel a31player) - { - System.Text.StringBuilder getPlayList = new System.Text.StringBuilder(); - getPlayList.AppendLine("<?xml version=\"1.0\"encoding=\"utf-8\"?>"); - getPlayList.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - getPlayList.AppendLine("<s:Body>"); - getPlayList.AppendLine("<u:BrowseQueue xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">"); - getPlayList.AppendLine("<QueueName>CurrentQueue</QueueName>"); - getPlayList.AppendLine("</u:BrowseQueue>"); - getPlayList.AppendLine("</s:Body>"); - getPlayList.AppendLine("</s:Envelope>"); - - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#BrowseQueue\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - byte[] recevieBytes = webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(getPlayList.ToString())); - return System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); - } - catch { } - return null; - } - /// <summary> - /// 鎾斁USB闊充箰鍛戒护 - /// </summary> - /// <param name="listName">鍒楄〃鍚嶇О</param> - /// <param name="number">鎾斁绱㈠紩</param> - public static void ListMusicPlay(string listName, object number, A31MusicModel a31player) - { - System.Text.StringBuilder playstrings = new System.Text.StringBuilder(); - playstrings.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>"); - playstrings.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - playstrings.AppendLine("<s:Body>"); - playstrings.AppendLine("<u:PlayQueueWithIndex xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">"); - playstrings.AppendLine("<QueueName>" + listName + "</QueueName>"); - playstrings.AppendLine("<Index>" + number + "</Index>"); - playstrings.AppendLine("</u:PlayQueueWithIndex>"); - playstrings.AppendLine("</s:Body>"); - playstrings.AppendLine("</s:Envelope>"); - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#PlayQueueWithIndex\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - byte[] recevieBytes = webClient.UploadData(new Uri("http://" + a31player.IPAddress + ":" + a31player.Port + "/upnp/control/PlayQueue1"), "POST", Encoding.UTF8.GetBytes(playstrings.ToString())); - var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); } catch { } } + /// <summary> + /// 璁惧鍚嶇О淇敼 + /// </summary> + public string EditDeviceName(string deviceId, string deviceName) + { + Dictionary<string, object> d = new Dictionary<string, object>(); + d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); + d.Add("deviceId", deviceId); + d.Add("name", deviceName); + + var requestJson = HttpUtil.GetSignRequestJson(d); + return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditDeviceName, requestJson).Code; + } /// <summary> - /// 鎺ㄩ�佹挱鏀惧懡浠� + /// 鑾峰彇闊充箰鍒楄〃 /// </summary> - /// <param name="musicInfo">鎾斁闊充箰</param> - /// <param name="listName">鍒楄〃鍚嶇О</param> - /// <param name="musicList">鎺ㄩ�佸垪琛�(榛樿鎺�50棣�)</param> - public static void PushList(MusicInfo musicInfo, string listName, List<MusicInfo> musicList, A31MusicModel a31player,string musicSource) + /// <param name="music"></param> + /// <returns></returns> + public void GetPalyList(Function music) { - - //鏈�澶у彂閫佺殑鏉℃暟 - int maxCount = 50; - //鎵惧嚭褰撳墠鐐瑰嚮闊充箰鐨勭储寮� - int statIndex = musicList.FindIndex((obj) => { return obj == musicInfo; }); - //鐐瑰嚮鍚庨潰杩樻湁澶氬皯鏉¢煶涔� - int count = musicList.Count - statIndex; - int endIndex = 0; - if (maxCount < count) - { - //濡傛灉鍚庨潰鐨勯煶涔愬ぇ浜庢渶澶ф暟锛岃缃悗闈㈡暟鎹殑鏈�澶х储寮� - endIndex = statIndex + maxCount - 1; - } - else - { - //濡傛灉鍚庨潰鏁版嵁涓嶅锛屽氨鐢ㄦ�绘暟鍑忓幓鏈�澶ф潯鏁帮紝寰楀埌寮�濮嬬储寮� - statIndex = musicList.Count - maxCount - 1; - endIndex = musicList.Count - 1; - } - //濡傛灉寮�濮嬬储寮曞皬浜�0锛岄偅灏辫缃负绗竴鏉¢煶涔� - if (statIndex < 0) - { - statIndex = 0; - } - - StringBuilder sb = new StringBuilder(); - sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); - sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - sb.AppendLine("<s:Body>"); - sb.AppendLine("<u:CreateQueue xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">"); - sb.AppendLine("<QueueContext><?xml version=\"1.0\"?>"); - sb.AppendLine("<PlayList>"); - sb.AppendLine("<ListName>DLNA" + listName + "</ListName>"); - sb.AppendLine("<ListInfo>"); - sb.AppendLine("<Radio>0</Radio>");// - sb.AppendLine("<SourceName>UPnPServer</SourceName>");// - sb.AppendLine("<MarkSearch>0</MarkSearch>"); - sb.AppendLine("<TrackNumber>" + (endIndex - statIndex + 1) + "</TrackNumber>"); - sb.AppendLine("<Quality>0</Quality>"); - sb.AppendLine("<UpdateTime>5367</UpdateTime>"); - sb.AppendLine("<LastPlayIndex>2</LastPlayIndex>"); - sb.AppendLine("<SwitchPageMode>0</SwitchPageMode>"); - sb.AppendLine("<CurrentPage>0</CurrentPage>"); - sb.AppendLine("<TotalPages>0</TotalPages>"); - sb.AppendLine("</ListInfo>"); - sb.AppendLine("<Tracks>"); - - int number = 1; - - for (int i = statIndex, Tracknumber = 1; i <= endIndex; i++, Tracknumber++) - { - var tempMusicInfo = musicList[i]; - - if (musicInfo == tempMusicInfo) - { - number = Tracknumber; - } - - if (tempMusicInfo.SourceType == "Local") - { - tempMusicInfo.URL = "http://" + new Shared.Net.NetWiFi().IpAddress + ":" + com.hdl.on.Server.Port + "/" + tempMusicInfo.ID; - } - - sb.AppendLine("<Track" + Tracknumber + ">"); - sb.AppendLine("<URL>" + tempMusicInfo.URL + "</URL>"); - sb.AppendLine("<Metadata>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;"); - sb.AppendLine("&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:song=&quot;www.wiimu.com/song/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;"); - sb.AppendLine("&lt;upnp:class&gt;object.item.audioItem.musicTrack&lt;/upnp:class&gt;"); - sb.AppendLine("&lt;item id=&quot;0&quot;&gt;"); - sb.AppendLine("&lt;song:subid&gt;&lt;/song:subid&gt;"); - sb.AppendLine("&lt;song:description&gt;unknown&lt;/song:description&gt;"); - sb.AppendLine("&lt;song:skiplimit&gt;6&lt;/song:skiplimit&gt;"); - sb.AppendLine("&lt;song:id&gt;" + tempMusicInfo.ID + "&lt;/song:id&gt;"); - sb.AppendLine("&lt;song:like&gt;0&lt;/song:like&gt;"); - sb.AppendLine("&lt;song:singerid&gt;0&lt;/song:singerid&gt;"); - sb.AppendLine("&lt;song:albumid&gt;" + tempMusicInfo.AlbumId + "&lt;/song:albumid&gt;"); - - sb.AppendLine("&lt;res protocolInfo=&quot;http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;&quot; duration=&quot;" + "0:0:0.0" + "&quot;&gt;" + tempMusicInfo.URL + "&lt;/res&gt;"); - - sb.AppendLine("&lt;dc:title&gt;" + tempMusicInfo.Title + "&lt;/dc:title&gt;"); - sb.AppendLine("&lt;dc:creator&gt;DJ Sanny J&lt;/dc:creator&gt;"); - if (musicSource== "鎴戠殑鍒楄〃") { - sb.AppendLine("&lt;upnp:artist&gt;" + listName + "&lt;/upnp:artist&gt;"); - } - else { - sb.AppendLine("&lt;upnp:artist&gt;" + tempMusicInfo.Artist + "&lt;/upnp:artist&gt;"); - } - sb.AppendLine("&lt;upnp:album&gt;" + tempMusicInfo.Album + "&lt;/upnp:album&gt;"); - sb.AppendLine("&lt;upnp:albumArtURI&gt;unknown&lt;/upnp:albumArtURI&gt;"); - sb.AppendLine("&lt;/item&gt;"); - sb.AppendLine("&lt;/DIDL-Lite&gt;"); - sb.AppendLine("</Metadata>"); - sb.AppendLine("<Id>" + tempMusicInfo.ID + "</Id>"); - sb.AppendLine("<Source>STATION-NETWORK</Source>");//UPnPServer - sb.AppendLine("<Key>" + tempMusicInfo.URL + "</Key>"); - sb.AppendLine("</Track" + Tracknumber + ">"); - } - sb.AppendLine("</Tracks>"); - sb.AppendLine("</PlayList>"); - sb.AppendLine("</QueueContext>"); - sb.AppendLine("</u:CreateQueue>"); - sb.AppendLine("</s:Body>"); - sb.AppendLine("</s:Envelope>"); - - SendMusicLists(a31player.IPAddress, a31player.Port, "CreateQueue", sb.ToString()); - - StringBuilder playString = new StringBuilder(); - playString.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); - playString.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); - playString.AppendLine("<s:Body>"); - playString.AppendLine("<u:PlayQueueWithIndex xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">"); - playString.AppendLine("<QueueName>DLNA" + listName + "</QueueName>"); - playString.AppendLine("<Index>" + number + "</Index>"); - playString.AppendLine("</u:PlayQueueWithIndex>"); - playString.AppendLine("</s:Body>"); - playString.AppendLine("</s:Envelope>"); - - Play(a31player.IPAddress, a31player.Port, playString.ToString()); - } - - static void SendMusicLists(string ip, int port, string soapAction, string listInfo) - { - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#" + soapAction + "\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); try { - byte[] recevieBytes = webClient.UploadData(new Uri("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(listInfo)); - var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); - } - catch(Exception e) - { - var d = e.Message; - } - } - - static void Play(string ip, int port, string info) - { - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#PlayQueueWithIndex\""); - webClient.Headers.Add("CONTENT-TYPE", "text/xml; charset=\"utf-8\""); - try - { - byte[] recevieBytes = webClient.UploadData(new Uri("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(info)); - var s = System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); + Dictionary<string, object> d = new Dictionary<string, object>(); + d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); + d.Add("deviceIds", new List<string> { music.deviceId }); + var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_PlayerList); + if (responsePackNew.Code != "0"||responsePackNew.Data == null ||responsePackNew.Data.ToString() == "") + { + return; + } + //鏁版嵁杩斿簭鍒楀寲涓篎unction瀵硅薄 + var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data); + var palyLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PalyListInfo>>(str); + if (palyLists == null) + { + palyLists =new List<PalyListInfo>(); + } + if (palyLists.Count > 0) + { + ///榛樿鎷跨涓�涓垪琛� + A31MusicModel.Current.palyLists = palyLists[0].playlist; + } } catch { - } + } - - - - static System.Threading.Thread thread; + /// <summary> - /// 淇敼钃濈墮鍚嶇О + ///璇锋眰鏈嶅姟鍣紙涓庝綇瀹呮湁鍏�:渚嬪锛沨omeId锛� /// </summary> - /// <param name="message"></param> - public static void ModifyBluetoothName(string message) + /// <returns></returns> + public ResponsePackNew RequestServerhomeId(object o, string api_Url, int mTimeout = 5) { - if (thread != null) - { - thread.Abort(); - } - thread = new System.Threading.Thread(() => - { - var tcpClient = new TcpClient() { ReceiveTimeout = 1000 }; - try - { - //杩涜杩炴帴 - tcpClient.Connect(new IPEndPoint(IPAddress.Parse(A31MusicModel.Current.IPAddress), 8899)); - var buffter = Encoding.UTF8.GetBytes(message); - var sendByes = new byte[20 + buffter.Length]; - sendByes[0] = 0x18; - sendByes[1] = 0x96; - sendByes[2] = 0x18; - sendByes[3] = 0x20; + var requestJson = HttpUtil.GetSignRequestJson(o); + return HttpUtil.RequestHttpsPostFroHome(api_Url, requestJson, mTimeout); - sendByes[4] = (byte)((buffter.Length & 0x000000FF) >> 0); - sendByes[5] = (byte)((buffter.Length & 0x0000FF00) >> 8); - sendByes[6] = (byte)((buffter.Length & 0x00FF0000) >> 16); - sendByes[7] = (byte)((buffter.Length & 0xFF000000) >> 24); - - var checkSum = getCheckSum(buffter); - sendByes[8] = (byte)((checkSum & 0x000000FF) >> 0); - sendByes[9] = (byte)((checkSum & 0x0000FF00) >> 8); - sendByes[10] = (byte)((checkSum & 0x00FF0000) >> 16); - sendByes[11] = (byte)((checkSum & 0xFF000000) >> 24); - - sendByes[16] = 0x08; - - Array.Copy(buffter, 0, sendByes, 20, buffter.Length); - tcpClient.GetStream().Write(sendByes, 0, sendByes.Length); - tcpClient.GetStream().Flush(); - - thread = null; - } - catch { } - finally - { - tcpClient.Close(); - } - }); - thread.Start(); } - static uint getCheckSum(byte[] buffer) - { - uint check_sum = 0; - - for (int i = 0; i < buffer.Length; i++) - { - check_sum += buffer[i]; - } - - return check_sum; - } - public class A31QQSong - { - public string title = string.Empty; - public string album = string.Empty; - public string creator = string.Empty; - } - } } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/UpdateThread.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/UpdateThread.cs deleted file mode 100644 index 664c342..0000000 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/UpdateThread.cs +++ /dev/null @@ -1,202 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using Shared; -using HDL_ON.UI.Music; -namespace HDL_ON.UI.UI2.FuntionControlView.Music -{ - public class UpdateThread - { - public UpdateThread() - { - } - /// <summary> - /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 - /// </summary> - /// <param name="frame">褰撳墠鐣岄潰</param> - /// <param name="middViewLayout">姣忎竴鏉¢煶涔愮殑涓绘帶浠�</param> - /// <param name="a31MusicModel">鐐瑰墠鎾斁鍣�</param> - public static void updateThread(FrameLayout frame, VerticalRefreshLayout middViewLayout, A31MusicModel a31MusicModel) - { - System.Threading.Thread updateSelectedMusicThread = new System.Threading.Thread(() => - { - while (frame.Parent != null) - { - //A31MusicModel.LogMusic("宸插惎鍔ㄦ洿鏂伴煶涔愬垪琛ㄦ煇涓�鏉¢煶涔愮姸鎬佺殑绾跨▼"); - System.Threading.Thread.Sleep(1000); - Application.RunOnMainThread(() => - { - try - { - for (int i = 0; i < middViewLayout.ChildrenCount; i++) - { - RowLayout view = (RowLayout)middViewLayout.GetChildren(i); - var volIconBtn = (Button)view.GetChildren(0);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button - var songNameBtn = (Button)view.GetChildren(1);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button - var artistNameBtn = (Button)view.GetChildren(2);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button - if (a31MusicModel.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString()) - { - volIconBtn.Visible = true; - songNameBtn.TextColor = UI.Music.MusicColor.SelectedColor; - songNameBtn.X = Application.GetRealWidth(48); - artistNameBtn.X = songNameBtn.Right; - artistNameBtn.TextColor = UI.Music.MusicColor.SelectedColor; - } - else - { - volIconBtn.Visible = false; - songNameBtn.TextColor = UI.Music.MusicColor.MusicTxet14Color; - songNameBtn.X = Application.GetRealWidth(16); - artistNameBtn.X = songNameBtn.Right; - artistNameBtn.TextColor = UI.Music.MusicColor.MusicNoTxetColor; - } - - - } - } - catch { } - - }); - } - }); - updateSelectedMusicThread.Start(); - } - /// <summary> - /// 鎾斁闊充箰 - /// </summary> - /// <param name="middViewLayout">涓婁笅鎷夊姩鐖舵帶浠�</param> - /// <param name="musicSource">闊充箰婧�</param> - /// <param name="listName">鎾斁鍒楄〃鍚�</param> - /// <param name="musicList">鎾斁闊充箰鍒楄〃</param> - /// <param name="a31MusicModel">闊充箰鎾斁鍣�</param> - public static void playMusuc(VerticalRefreshLayout middViewLayout, string musicSource, string listName,List<MusicInfo> musicList, A31MusicModel a31MusicModel, FrameLayout frame=null) - { - for (int i = 0; i < musicList.Count; i++) - { - var songs = musicList[i]; - if (songs == null) - { - continue; - } - UI.Music.View.SongView songView = new UI.Music.View.SongView(); - songView.SongFrameLayout(middViewLayout, songs); - switch (musicSource) - { - case "鏈湴闊充箰": - { - songs.URL = "http://" + new Shared.Net.NetWiFi().IpAddress + ":" + com.hdl.on.Server.Port + "/" + songs.ID; - } - break; - case "USB": - { - songView.clickBtn.Tag = i + 1; - } - break; - case "鎴戠殑鍒楄〃": - { - ///鍒犻櫎鎺т欢 - var delBtn = new Button - { - BackgroundColor = MusicColor.MusicDelColor, - Text = Language.StringByID(StringId.delMusic), - TextColor = MusicColor.WhiteColor, - TextSize = TextSize.Text16, - }; - songView.musicViewFl.AddRightView(delBtn); - delBtn.MouseUpEventHandler += (sender, e) => - { - musicList.Remove(songs); - A31MusicModel.Save(); - songView.musicViewFl.RemoveFromParent(); - }; - } - break; - case "鎾斁鍒楄〃": - { - songView.loveIcon.Visible = false; - songView.addIcon.Visible = false; - var wText = songView.songBtn.GetTextWidth() + Application.GetRealWidth(15); - if (wText > Application.GetRealWidth(280)) - { - wText = Application.GetRealWidth(280);//(姝屾洸+姝屾墜)瀹藉害鏈�澶у�兼椂220 - } - songView.songBtn.Width = wText; - songView.singerBtn.X = songView.songBtn.Right; - songView.singerBtn.Width = Application.GetRealWidth(280) - wText;//姝屽悕闀垮害灏忎簬220鎵嶅彲浠ユ樉绀烘瓕鎵嬪嚭鏉� - songView.singerBtn.Text = string.IsNullOrEmpty(songs.Artist) ? "-Unkonw" : "-" + songs.Artist.Trim(); - songView.clickBtn.Width = Application.GetRealWidth(344); - songView.clickBtn.Tag = i + 1;//鏍囪鎾斁鍝竴棣栨瓕鏇� - } - break; - } - - //娣诲姞鍠滅埍闊充箰鎺т欢 - songView.loveIcon.MouseUpEventHandler += (sender, e) => - { - songView.loveIcon.IsSelected = !songView.loveIcon.IsSelected; - if (songView.loveIcon.IsSelected) - { - ///鏌ユ壘闊充箰鏄惁瀛樺湪鍦ㄥ垪琛� - var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL); - if (music1 == null) - { - ///娌℃湁瀛樺湪灏辨坊鍔� - A31MusicModel.Current.LoveMusicInfoList.Add(songs); - } - } - else - { - ///鏌ユ壘闊充箰鏄惁瀛樺湪鍦ㄥ垪琛� - var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL); - if (music1 != null) - { - ///瀛樺湪灏卞垹闄� - A31MusicModel.Current.LoveMusicInfoList.Remove(songs); - } - - if (musicSource == "鎴戠殑鏈�鐖�") - { - songView.musicViewFl.RemoveFromParent(); - } - - } - A31MusicModel.Save(); - }; - //娣诲姞鍒版垜鐨勫垪琛� - songView.addIcon.MouseUpEventHandler = (sender, e) => - { - new HDL_ON.UI.Music.View.DialogView { }.FieListView(songs); - }; - ///鐐瑰嚮鎾斁浜嬩欢 - songView.clickBtn.MouseUpEventHandler += (sender, e) => - { - System.Threading.Tasks.Task.Run(() => - { - System.Threading.Thread.Sleep(50); - Application.RunOnMainThread(() => - { - //绉婚櫎鐣岄潰 - A31MusicModel.Current.A31PlayStatus.Title = songView.songBtn.Text; - if (frame != null) - { - frame.RemoveFromParent(); - } - MainPage.BasePageView.RemoveViewByTag("Music"); - System.Threading.Tasks.Task.Run(() => - { - if (musicSource == "鏈湴闊充箰"|| musicSource == "鎴戠殑鏈�鐖�"|| musicSource == "鎴戠殑鍒楄〃") - { - SendMethod.PushList(songs, listName, musicList, a31MusicModel,musicSource); - } - else if (musicSource == "USB"|| musicSource == "鎾斁鍒楄〃") - { - SendMethod.ListMusicPlay(listName, songView.clickBtn.Tag, A31MusicModel.Current); - } - }); - }); - }); - }; - - } - } - } -} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/View/DialogView.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/View/DialogView.cs index 1c15666..0da47b3 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/View/DialogView.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/View/DialogView.cs @@ -9,7 +9,7 @@ ///寮圭獥鏂囦欢澶瑰垪琛ㄧ晫闈� /// </summary> /// <param name="musicInfo"></param> - public void FieListView(MusicInfo musicInfo) + public void FieListView(Songs musicInfo) { #region //涓绘帶浠� @@ -114,7 +114,7 @@ FileView(dialog, verticalScrolViewLayout, musicInfo); } - void FileView(Dialog dialog, VerticalScrolViewLayout verticalScrolViewLayout, MusicInfo musicInfo) + void FileView(Dialog dialog, VerticalScrolViewLayout verticalScrolViewLayout, Songs musicInfo) { verticalScrolViewLayout.RemoveAll(); for (int i = 0; i < A31MusicModel.Current.FileLists.Count; i++) @@ -207,7 +207,7 @@ EventHandler<MouseEventArgs> click = (sender, e) => { - if (null == list.MusicInfoList.Find((music) => music.URL == musicInfo.URL)) + if (null == list.MusicInfoList.Find((music) => music.name == musicInfo.name)) { list.MusicInfoList.Add(musicInfo); A31MusicModel.Save(); @@ -222,1241 +222,6 @@ } - } - /// <summary> - /// 閫変腑缁勫悎鐨勬挱鏀惧櫒鐨勭晫闈� - /// </summary> - public void PlayMergence(A31MusicModel a31MusicModel) - { - - #region - - //涓绘帶浠� - Dialog dialog = new Dialog() - { - BackgroundColor = MusicColor.PopupBackgroundColor, - }; - dialog.Show(); - //鐖舵帶浠� - FrameLayout frame = new FrameLayout { }; - dialog.AddChidren(frame); - frame.MouseUpEventHandler += (sen, e) => - { - dialog.Close(); - }; - //鐧借壊蹇埗鎺т欢 - FrameLayout dialogFra = new FrameLayout() - { - X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(397), - Width = Application.GetRealWidth(344), - Height = Application.GetRealHeight(250), - BackgroundColor = MusicColor.WhiteColor, - Radius = (uint)Application.GetRealHeight(12), - }; - frame.AddChidren(dialogFra); - //鏄剧ず澶撮儴淇℃伅鐖舵帶浠� - FrameLayout topFra = new FrameLayout() - { - Width = Application.GetRealWidth(344), - Height = Application.GetRealHeight(50), - }; - dialogFra.AddChidren(topFra); - //鍙栨秷鎺т欢 - Button cancelnBtn = new Button - { - X = Application.GetRealWidth(20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(60), - Height = Application.GetRealHeight(20), - TextID = StringId.cancelMusic, - TextAlignment = TextAlignment.CenterLeft, - TextColor = MusicColor.MusicNoTxetColor, - TextSize = TextSize.Text14, - }; - topFra.AddChidren(cancelnBtn); - cancelnBtn.MouseUpEventHandler += (sen, e) => - { - dialog.Close(); - }; - //鏍囬鎺т欢 - Button txetBtn = new Button - { - X = cancelnBtn.Right + Application.GetRealWidth(20), - Y = Application.GetRealHeight(14), - Width = Application.GetRealWidth(152), - Height = Application.GetRealHeight(22), - TextColor = MusicColor.TextColor, - TextSize = TextSize.Text16, - TextAlignment = TextAlignment.Center, - TextID = StringId.selectedMergence, - IsBold = true, - }; - topFra.AddChidren(txetBtn); - - //纭鎺т欢 - Button confirmBtn = new Button - { - X = Application.GetRealWidth(344 - 60 - 20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(60), - Height = Application.GetRealHeight(20), - TextID = StringId.confirmMusic, - TextAlignment = TextAlignment.CenterRight, - TextColor = MusicColor.SelectedColor, - TextSize = TextSize.Text14, - }; - topFra.AddChidren(confirmBtn); - - VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout - { - Y = Application.GetRealHeight(50), - Height = dialogFra.Height - Application.GetRealHeight(50), - Width = Application.GetRealWidth(344), - }; - dialogFra.AddChidren(verticalScrolViewLayout); - var playList1 = new List<A31MusicModel>(); - for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) - { - var player = A31MusicModel.A31MusicModelList[i]; - if (!player.IsOnLine) - { - //涓嶅湪绾夸笉鏄剧ず; - continue; - } - RowLayout PlayRow = new RowLayout - { - Height = Application.GetRealHeight(50), - LineColor = MusicColor.WhiteColor, - SubViewWidth = Application.GetRealWidth(80),//鏀瑰彉缂栬緫鎺т欢瀹藉害澶氬皯锛� - }; - verticalScrolViewLayout.AddChidren(PlayRow); - - - //鎾斁鍣ㄥ悕绉版帶浠� - Button PlayNameBtn = new Button - { - X = Application.GetRealWidth(20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(150), - Height = Application.GetRealHeight(20), - TextColor = MusicColor.TextColor, - TextSize = TextSize.Text14, - TextAlignment = TextAlignment.CenterLeft, - Text = NamePlayer(player), - }; - PlayRow.AddChidren(PlayNameBtn); - - //閫変腑鍥炬爣鎺т欢 - Button selectedIconBtn = new Button - { - X = Application.GetRealWidth(303), - Y = Application.GetRealHeight(11), - Width = Application.GetRealWidth(28), - Height = Application.GetRealWidth(28), - UnSelectedImagePath = "MusicIcon/noSelectedIcon.png", - SelectedImagePath = "MusicIcon/selectedIcon.png", - }; - PlayRow.AddChidren(selectedIconBtn); - - - ///鍔犲ぇ鍑犵偣鑼冨洿 - Button clickBtn = new Button - { - Height = Application.GetRealHeight(50), - }; - PlayRow.AddChidren(clickBtn); - if (a31MusicModel.UniqueDeviceName == player.UniqueDeviceName) - { - clickBtn.IsSelected = selectedIconBtn.IsSelected = true; - playList1.Add(a31MusicModel); - } - clickBtn.MouseUpEventHandler += (sender, e) => - { - clickBtn.IsSelected = !clickBtn.IsSelected; - selectedIconBtn.IsSelected = clickBtn.IsSelected; - var musicPlayer = playList1.Find((c) => c.UniqueDeviceName == player.UniqueDeviceName); - if (selectedIconBtn.IsSelected) - { - if (musicPlayer == null) - { - playList1.Add(player); - } - } - else - { - if (musicPlayer != null) - { - playList1.Remove(player); - } - } - }; - //绾� - Button lineBtn = new Button - { - Y = PlayRow.Height - 1, - X = Application.GetRealWidth(20), - Width = Application.GetRealWidth(304), - Height = 1, - BackgroundColor = MusicColor.LineColor, - }; - PlayRow.AddChidren(lineBtn); - } - #endregion - confirmBtn.MouseUpEventHandler += (sender, e) => - { - - if (playList1.Count <= 1) - { - new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.selectAtLeastTwoPlayers), false); - return; - } - int number = 0; - foreach (var musin in playList1) - { - if (musin.ServerClientType == 1) - { - number++; - } - } - if (number >= 2) - { - new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.cannotSelectTwoOrMoreMainPlayersToCombine), false); - //濡傛灉閮芥槸涓绘挱鏀炬垜灏变笉鑳界粍鍚�; - return; - } - ///鏌ヨ鏄惁宸茬粡瀛樺湪涓绘挱鏀�; - var host_Music_If = playList1.Find((c) => c.ServerClientType == 1); - if (host_Music_If == null) - { - var playList2 = new List<A31MusicModel>(); - for (int i = 0; i < playList1.Count; i++) - { - var musics = playList1[i]; - if (musics.A31PlayStatus.status == "play") - { - playList2.Add(musics); - } - } - - if (playList2.Count == 0) - { - SelectedPlayerView(dialog, playList1, playList1); - } - else if (playList2.Count == 1) - { - //鍙湁涓�涓挱鏀惧櫒鍦ㄦ挱鏀�,榛樿涓轰富鎾彂鍣�; - dialog.Close(); - var player = playList2[0]; - MergeThreading(player, playList1); - } - else - { - SelectedPlayerView(dialog, playList1, playList2); - } - } - else - { - dialog.Close(); - MergeThreading(host_Music_If, playList1); - } - }; - } - /// <summary> - /// 閫変腑鏌愪釜闊充箰涓轰富鎾斁鍣ㄧ殑鐣岄潰 - /// </summary> - /// <param name="musicList1">鏄剧ず灏嗚缁勫悎鐨勬挱鏀惧櫒鍒楄〃</param> - /// /// <param name="musicList2">鏄剧ず鍦ㄦ挱鏀鹃煶涔愭挱鏀惧櫒鍒楄〃</param> - void SelectedPlayerView(Dialog dialogF, List<A31MusicModel> musicList1, List<A31MusicModel> musicList2) - { - #region - //涓绘帶浠� - Dialog dialog = new Dialog() - { - //BackgroundColor = Color.PopupBackgroundColor, - }; - dialog.Show(); - //鐖舵帶浠� - FrameLayout frame = new FrameLayout { }; - dialog.AddChidren(frame); - frame.MouseUpEventHandler += (sen, e) => - { - dialog.Close(); - }; - //鐧借壊蹇埗鎺т欢 - FrameLayout dialogFra = new FrameLayout() - { - X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(397), - Width = Application.GetRealWidth(344), - Height = Application.GetRealHeight(250), - BackgroundColor = MusicColor.WhiteColor, - Radius = (uint)Application.GetRealHeight(12), - }; - frame.AddChidren(dialogFra); - //鏄剧ず澶撮儴淇℃伅鐖舵帶浠� - FrameLayout topFra = new FrameLayout() - { - Width = Application.GetRealWidth(344), - Height = Application.GetRealHeight(50), - }; - dialogFra.AddChidren(topFra); - //鍙栨秷鎺т欢 - Button cancelnBtn = new Button - { - X = Application.GetRealWidth(20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(60), - Height = Application.GetRealHeight(20), - TextID = StringId.cancelMusic, - TextAlignment = TextAlignment.CenterLeft, - TextColor = MusicColor.MusicNoTxetColor, - TextSize = TextSize.Text14, - }; - topFra.AddChidren(cancelnBtn); - cancelnBtn.MouseUpEventHandler += (sen, e) => - { - dialog.Close(); - }; - //鏍囬鎺т欢 - Button txetBtn = new Button - { - X = cancelnBtn.Right + Application.GetRealWidth(20), - Y = Application.GetRealHeight(14), - Width = Application.GetRealWidth(152), - Height = Application.GetRealHeight(22), - TextColor = MusicColor.TextColor, - TextSize = TextSize.Text16, - TextAlignment = TextAlignment.Center, - TextID = StringId.readyPlay, - IsBold = true, - }; - topFra.AddChidren(txetBtn); - //纭鎺т欢 - Button confirmBtn = new Button - { - X = Application.GetRealWidth(344 - 60 - 20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(60), - Height = Application.GetRealHeight(20), - TextID = StringId.confirmMusic, - TextAlignment = TextAlignment.CenterRight, - TextColor = MusicColor.SelectedColor, - TextSize = TextSize.Text14, - }; - topFra.AddChidren(confirmBtn); - - VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout - { - Y = Application.GetRealHeight(50), - Height = dialogFra.Height - Application.GetRealHeight(50), - Width = Application.GetRealWidth(344), - }; - dialogFra.AddChidren(verticalScrolViewLayout); - //璁板綍閫変腑鐘舵�� - Button selectedBtn = new Button() { Name = "No" }; - for (int i = 0; i < musicList2.Count; i++) - { - var player = musicList2[i]; - RowLayout addFlieRow = new RowLayout - { - Height = Application.GetRealHeight(50), - LineColor = MusicColor.WhiteColor, - }; - verticalScrolViewLayout.AddChidren(addFlieRow); - - if (player.A31PlayStatus.status == "play") - { - Button songNameBtn = new Button - { - X = Application.GetRealWidth(20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(150), - Height = Application.GetRealHeight(20), - TextColor = MusicColor.TextColor, - TextSize = TextSize.Text14, - TextAlignment = TextAlignment.CenterLeft, - Text = player.A31PlayStatus.Title, - }; - addFlieRow.AddChidren(songNameBtn); - - var wText = songNameBtn.GetTextWidth();//鑾峰彇鏂囨湰瀹藉害 - if (wText >Application.GetRealWidth(220)) - { - songNameBtn.Width = Application.GetRealWidth(220); - } - else - { - songNameBtn.Width = wText + Application.GetRealWidth(15); - } - //姝屾墜鎺т欢 - Button singerBtn = new Button - { - X = songNameBtn.Right, - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(220)- wText, - Height = Application.GetRealHeight(20), - TextColor = MusicColor.MusicNoTxetColor, - TextSize = TextSize.Text12, - TextAlignment = TextAlignment.CenterLeft, - Text = "-" + player.A31PlayStatus.Artist.Trim(), - }; - addFlieRow.AddChidren(singerBtn); - } - else - { - //鎾斁鍣ㄥ悕绉版帶浠� - Button PlayNameBtn = new Button - { - X = Application.GetRealWidth(20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(150), - Height = Application.GetRealHeight(20), - TextColor = MusicColor.TextColor, - TextSize = TextSize.Text14, - TextAlignment = TextAlignment.CenterLeft, - Text = NamePlayer(player), - }; - addFlieRow.AddChidren(PlayNameBtn); - - } - - //閫変腑鍥炬爣鎺т欢 - Button selectedIconBtn = new Button - { - X = Application.GetRealWidth(303), - Y = Application.GetRealHeight(11), - Width = Application.GetRealWidth(28), - Height = Application.GetRealWidth(28), - UnSelectedImagePath = "MusicIcon/noSelectedIcon.png", - SelectedImagePath = "MusicIcon/selectedIcon.png", - Tag = player, - }; - addFlieRow.AddChidren(selectedIconBtn); - ///鍔犲ぇ鍑犵偣鑼冨洿 - Button clickBtn = new Button - { - Height = Application.GetRealHeight(50), - }; - addFlieRow.AddChidren(clickBtn); - clickBtn.MouseUpEventHandler += (sender, e) => - { - selectedBtn.IsSelected = false; - selectedBtn = selectedIconBtn; - selectedBtn.Name = "Yes"; - selectedBtn.IsSelected = true; - }; - //绾� - Button lineBtn = new Button - { - Y = addFlieRow.Height - 1, - X = Application.GetRealWidth(20), - Width = Application.GetRealWidth(304), - Height = 1, - BackgroundColor = MusicColor.LineColor, - }; - addFlieRow.AddChidren(lineBtn); - } - #endregion - confirmBtn.MouseUpEventHandler += (sender, e) => - { - if (selectedBtn.Name.ToString() == "No") - { - new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.noSelectedPlay), false); - return; - } - dialogF.Close(); - dialog.Close(); - - var serverMusic = selectedBtn.Tag as A31MusicModel; - MergeThreading(serverMusic, musicList1); - }; - - } - /// <summary> - /// 閫変腑瑙i櫎缁勫悎鐨勬挱鏀惧櫒鐨勭晫闈� - /// </summary> - public void DetachPlayMergence(A31MusicModel a31player) - { - - #region - //涓绘帶浠� - Dialog dialog = new Dialog() - { - BackgroundColor = MusicColor.PopupBackgroundColor, - }; - dialog.Show(); - //鐖舵帶浠� - FrameLayout frame = new FrameLayout { }; - dialog.AddChidren(frame); - frame.MouseUpEventHandler += (sen, e) => - { - dialog.Close(); - }; - //鐧借壊蹇埗鎺т欢 - FrameLayout dialogFra = new FrameLayout() - { - X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(397), - Width = Application.GetRealWidth(344), - Height = Application.GetRealHeight(250), - BackgroundColor = MusicColor.WhiteColor, - Radius = (uint)Application.GetRealHeight(12), - }; - frame.AddChidren(dialogFra); - //鏄剧ず澶撮儴淇℃伅鐖舵帶浠� - FrameLayout topFra = new FrameLayout() - { - Width = Application.GetRealWidth(344), - Height = Application.GetRealHeight(50), - }; - dialogFra.AddChidren(topFra); - //鍙栨秷鎺т欢 - Button cancelnBtn = new Button - { - X = Application.GetRealWidth(20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(60), - Height = Application.GetRealHeight(20), - TextID = StringId.cancelMusic, - TextAlignment = TextAlignment.CenterLeft, - TextColor = MusicColor.MusicNoTxetColor, - TextSize = TextSize.Text14, - }; - topFra.AddChidren(cancelnBtn); - cancelnBtn.MouseUpEventHandler += (sen, e) => - { - dialog.Close(); - }; - //鏍囬鎺т欢 - Button txetBtn = new Button - { - X = cancelnBtn.Right + Application.GetRealWidth(20), - Y = Application.GetRealHeight(14), - Width = Application.GetRealWidth(152), - Height = Application.GetRealHeight(22), - TextColor = MusicColor.TextColor, - TextSize = TextSize.Text16, - TextAlignment = TextAlignment.Center, - TextID = StringId.checkTheReleasePlayer, - //Text = "閫変腑瑙i櫎鎾斁鍣�", - IsBold = true, - }; - topFra.AddChidren(txetBtn); - - //纭鎺т欢 - Button confirmBtn = new Button - { - X = Application.GetRealWidth(344 - 60 - 20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(60), - Height = Application.GetRealHeight(20), - TextID = StringId.confirmMusic, - TextAlignment = TextAlignment.CenterRight, - TextColor = MusicColor.SelectedColor, - TextSize = TextSize.Text14, - }; - topFra.AddChidren(confirmBtn); - - VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout - { - Y = Application.GetRealHeight(50), - Height = dialogFra.Height - Application.GetRealHeight(50), - Width = Application.GetRealWidth(344), - }; - dialogFra.AddChidren(verticalScrolViewLayout); - - var playList1 = new List<A31MusicModel>(); - playList1.Add(a31player); - for (int i = 0; i < a31player.Slave.slave_list.Count; i++) - { - var slave = a31player.Slave.slave_list[i]; - var music_If = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == slave.uuid.Replace("uuid:", "")); - if (music_If != null) - { - playList1.Add(music_If); - } - } - - - var playList2 = new List<A31MusicModel>(); - for (int i = 0; i < playList1.Count; i++) - { - var player = playList1[i]; - RowLayout PlayRow = new RowLayout - { - Height = Application.GetRealHeight(50), - LineColor = MusicColor.WhiteColor, - SubViewWidth = Application.GetRealWidth(80),//鏀瑰彉缂栬緫鎺т欢瀹藉害澶氬皯锛� - }; - verticalScrolViewLayout.AddChidren(PlayRow); - - - //鎾斁鍣ㄥ悕绉版帶浠� - Button PlayNameBtn = new Button - { - X = Application.GetRealWidth(20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(150), - Height = Application.GetRealHeight(20), - TextColor = MusicColor.TextColor, - TextSize = TextSize.Text14, - TextAlignment = TextAlignment.CenterLeft, - Text = NamePlayer(player), - }; - PlayRow.AddChidren(PlayNameBtn); - - - //閫変腑鍥炬爣鎺т欢 - Button selectedIconBtn = new Button - { - X = Application.GetRealWidth(303), - Y = Application.GetRealHeight(11), - Width = Application.GetRealWidth(28), - Height = Application.GetRealWidth(28), - UnSelectedImagePath = "MusicIcon/noSelectedIcon.png", - SelectedImagePath = "MusicIcon/selectedIcon.png", - }; - PlayRow.AddChidren(selectedIconBtn); - - ///鍔犲ぇ鍑犵偣鑼冨洿 - Button clickBtn = new Button - { - Height = Application.GetRealHeight(50), - Tag = player.UniqueDeviceName, - }; - PlayRow.AddChidren(clickBtn); - - clickBtn.MouseUpEventHandler += (sender, e) => - { - clickBtn.IsSelected = !clickBtn.IsSelected; - selectedIconBtn.IsSelected = clickBtn.IsSelected; - var uuid = playList2.Find((obj) => obj.UniqueDeviceName == clickBtn.Tag.ToString()); - if (selectedIconBtn.IsSelected) - { - if (uuid == null) - { - playList2.Add(player); - } - } - else - { - if (uuid != null) - { - playList2.Remove(player); - } - } - }; - //绾� - Button lineBtn = new Button - { - Y = PlayRow.Height - 1, - X = Application.GetRealWidth(20), - Width = Application.GetRealWidth(304), - Height = 1, - BackgroundColor = MusicColor.LineColor, - }; - PlayRow.AddChidren(lineBtn); - } - #endregion - confirmBtn.MouseUpEventHandler += (sender, e) => - { - if (playList1.Count == 0) - { - new PublicAssmebly().TipMsgAutoClose(Language.StringByID(StringId.noCheckTheReleasePlayer), false); - return; - } - dialog.Close(); - RemoveThreading(a31player, playList2); - }; - } - /// <summary> - /// 鍙戦�佺粍鍚堝懡浠ら�昏緫澶勭悊鐨勬柟娉� - /// </summary> - /// <param name="serverMusic">涓绘挱鏀惧櫒</param> - /// <param name="musicList1"></param> - void MergeThreading(A31MusicModel serverMusic, List<A31MusicModel> musicList1) - { - A31MusicModel mainModel = null; - bool mainModelCollection = false; - MusicMain.loading.Start(Language.StringByID(StringId.inConfiguration)); - bool _if = false; - System.Threading.Tasks.Task.Run(() => - { - try - { - var statusEx = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=getStatusEx"); - if (statusEx == null) - { - statusEx = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=getStatusEx"); - } - if (statusEx == null) - { - return; - } - var serverIfon = Newtonsoft.Json.JsonConvert.DeserializeObject<A31Wifi>(statusEx); - if (serverIfon == null) - { - return; - } - string ssid = ""; - foreach (var b in serverIfon.ssid) - { - ssid += System.Convert.ToString(b, 16).ToUpper().Length < 2 ? "0" + System.Convert.ToString(b, 16).ToUpper() : System.Convert.ToString(b, 16).ToUpper(); - } - System.Threading.Thread.Sleep(1000); - for (int i = 0; i < musicList1.Count; i++) - { - var clientMusic = musicList1[i]; - if (clientMusic.UniqueDeviceName == serverMusic.UniqueDeviceName) - { - //杩囨护鎺変富鎾斁鍣�; - continue; - } - var dd = SendMethod.OpenWeb("http://" + clientMusic.IPAddress + "/httpapi.asp?command=ConnectMasterAp:ssid=" + ssid + ":ch=" + serverIfon.WifiChannel + ":auth=OPEN:encry=NONE:pwd=:chext=0:JoinGroupMaster:eth" + serverIfon.eth2 + ":wifi" + serverIfon.ra0 + ":uuid" + serverIfon.uuid); - if (null == SendMethod.OpenWeb("http://" + clientMusic.IPAddress + "/httpapi.asp?command=ConnectMasterAp:ssid=" + ssid + ":ch=" + serverIfon.WifiChannel + ":auth=OPEN:encry=NONE:pwd=:chext=0:JoinGroupMaster:eth" + serverIfon.eth2 + ":wifi" + serverIfon.ra0 + ":uuid" + serverIfon.uuid)) - { - if (null == SendMethod.OpenWeb("http://" + clientMusic.IPAddress + "/httpapi.asp?command=ConnectMasterAp:ssid=" + ssid + ":ch=" + serverIfon.WifiChannel + ":auth=OPEN:encry=NONE:pwd=:chext=0:JoinGroupMaster:eth" + serverIfon.eth2 + ":wifi" + serverIfon.ra0 + ":uuid" + serverIfon.uuid)) - { - - } - } - System.Threading.Thread.Sleep(1000);//绛夊緟1绉掑啀鍙戞暟鎹� - } - DateTime dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 15 * 1000) - { - System.Threading.Thread.Sleep(1000); - try - { - var result = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); - if (result != null && result != "Failed") - { - var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result); - if (tmepSlaves != null && tmepSlaves.slave_list != null && tmepSlaves.slave_list.Count != 0) - { - string str = serverMusic.Name; - for (int j = 0; j < A31MusicModel.A31MusicModelList.Count; j++) - { - var music = A31MusicModel.A31MusicModelList[j]; - if(music.collect && !mainModelCollection) - { - mainModelCollection = true; - } - if (music.UniqueDeviceName == serverMusic.UniqueDeviceName) - { - music.ServerClientType = 1; - mainModel = music; - music.Slave = tmepSlaves; - //杩囨护鎺変富鎾斁鍣�; - continue; - } - var slave_Ifon = tmepSlaves.slave_list.Find((obj) => obj.uuid.Replace("uuid:", "") == music.UniqueDeviceName); - if (null != slave_Ifon) - { - str = str + "+" + slave_Ifon.name; - //宸茬粡娣诲姞鎴愬姛 - music.ServerClientType = -1; - music.IsCanShow = false; - music.IsOnLine = false; - music.IPAddress = slave_Ifon.ip; - music.MainPlayIP = serverMusic.IPAddress; - _if = true; - } - } - serverMusic.MainPlayName = str; - foreach(var music in A31MusicModel.A31MusicModelList) - { - if(music.ServerClientType == 1) - { - music.MainPlayCollection = mainModelCollection; - } - } - A31MusicModel.Save(); - break; - } - } - } - catch { } - } - } - catch { } - finally - { - Application.RunOnMainThread(() => - { - MusicMain.loading.Hide(); - ///鍙互鎻愮ず閰嶇疆澶辫触; - if (_if) - { - //閰嶇疆鎴愬姛鎵嶅彲浠ュ埛鏂扮晫闈� - MainPage.BasePageView.RemoveViewByTag("MusicMain"); - var musicMain = new MusicMain(); - MainPage.BasePageView.AddChidren(musicMain); - musicMain.Show(); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - } - }); - } - }); - - } - /// <summary> - /// 瑙i櫎缁勫悎鍛戒护閫昏緫澶勭悊鐨勬柟娉� - /// </summary> - /// <param name="a31player">涓绘挱鏀惧櫒</param> - /// <param name="playList1"></param> - void RemoveThreading(A31MusicModel a31player, List<A31MusicModel> playList1) - { - MusicMain.loading.Start(Language.StringByID(StringId.lifting)); - var slaveList = new List<Slave>(); - slaveList.AddRange(a31player.Slave.slave_list); - // bool host_If = false; //琛ㄧず鏄惁鏄剧ず瑙i櫎鐨勬挱鏀� - bool _if = false; - System.Threading.Tasks.Task.Run(() => - { - try - { - var play_If = playList1.Find((obj) => obj.UniqueDeviceName == a31player.UniqueDeviceName); - if (play_If == null) - { - //瀛愰煶绠变笌涓婚煶绠辨柇寮�鐨勫懡浠� - for (int i = 0; i < playList1.Count; i++) - { - var clientMusic = playList1[i]; - if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:SlaveKickout:" + clientMusic.IPAddress)) - { - if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:SlaveKickout:" + clientMusic.IPAddress)) - { - - } - } - ///姣忚В闄や竴涓挱鏀惧櫒闇�瑕佺瓑寰�3绉� - System.Threading.Thread.Sleep(3000);//绛夊緟3绉掑啀鍙戞暟鎹� - } - } - else - { - //瑙f暎缁勭殑鍛戒护 - if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:Ungroup")) - { - if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:Ungroup")) - { - - } - } - } - DateTime dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 12 * 1000) - { - System.Threading.Thread.Sleep(1000); - try - { - var result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); - if (result != null && result != "Failed") - { - var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result); - if (tmepSlaves != null) - { - if (tmepSlaves.slave_list.Count == 0) - { - var host_music = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == a31player.UniqueDeviceName); - if (host_music != null) - { - host_music.ServerClientType = 0;//瑙i櫎涓讳粠鍏崇郴 - host_music.MainPlayName = ""; - } - for (int a = 0; a < slaveList.Count; a++) - { - var uuid = slaveList[a].uuid.Replace("uuid:", ""); - var music = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == uuid); - if (music != null) - { - music.ServerClientType = 0;//瑙i櫎涓讳粠鍏崇郴 - music.IsCanShow = true;//鍏佽鏄剧ず - music.IsOnLine = false;//鍏堜笉鍏佽璇诲彇 - } - } - } - else - { - for (int b = 0; b < tmepSlaves.slave_list.Count; b++) - { - var uuid = tmepSlaves.slave_list[b].uuid.Replace("uuid:", ""); - var music = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == uuid); - if (music != null) - { - music.ServerClientType = 0;//瑙i櫎涓讳粠鍏崇郴 - music.IsCanShow = true;//鍏佽鏄剧ず - music.IsOnLine = false;//鍏堜笉鍏佽璇诲彇 - } - } - } - - var host_a31player = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == a31player.UniqueDeviceName); - string str = host_a31player.Name; - for (int b = 0; b < tmepSlaves.slave_list.Count; b++) - { - str = str + "+" + tmepSlaves.slave_list[b].name; - } - host_a31player.MainPlayName = str;///鏀瑰彉涓绘挱鏀惧櫒鐨勬樉绀哄悕绉� - _if = true;//瑙i櫎鎴愬姛 - A31MusicModel.Save(); - break; - } - } - - } - catch { } - } - } - catch { } - finally - { - Application.RunOnMainThread(() => - { - MusicMain.loading.Hide(); - ///鍙互鎻愮ず瑙i櫎澶辫触; - if (_if) - { - //瑙i櫎鎴愬姛鎵嶅彲浠ュ埛鏂扮晫闈� - MainPage.BasePageView.RemoveViewByTag("MusicMain"); - var musicMain = new MusicMain(); - MainPage.BasePageView.AddChidren(musicMain); - musicMain.Show(); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - } - }); - } - }); - - } - /// <summary> - /// 鎾斁鍣ㄥ悕绉� - /// </summary> - public string NamePlayer(A31MusicModel a31player) - { - if (a31player.ServerClientType == 1) - { - return a31player.MainPlayName; - } - else - { - return a31player.Name; - } - } - - List<A31MusicModel> volumePlayList = new List<A31MusicModel>(); - A31MusicModel currVolumePlay = null;//褰撳墠鐨勬挱鏀惧櫒 - int startVolume = 0;//涔嬪墠鐨勯煶閲� - int endVolume = 0;//鐜板湪鐨勯煶閲� - string if_volume ="";//鏍囪鏄皟鑺傛�婚煶閲忚繕鏄崟涓挱鏀惧櫒闊抽噺; - /// <summary> - /// 鎾斁鍣ㄩ煶閲忕殑鐣岄潰 - /// </summary> - /// <param name="a31player">涓绘挱鏀惧櫒</param> - public void PlayerVolumeView(A31MusicModel a31player) - { - volumePlayList.Clear(); - for (int i = 0; i < a31player.Slave.slave_list.Count; i++) - { - var slave = a31player.Slave.slave_list[i]; - var music_If = A31MusicModel.A31MusicModelList.Find((c) => c.UniqueDeviceName == slave.uuid.Replace("uuid:", "")); - if (music_If != null) - { - music_If.ServerClientType = -1; - music_If.A31PlayStatus.vol = slave.volume; - volumePlayList.Add(music_If); - } - } - volumePlayList.Add(a31player); - #region - //涓绘帶浠� - Dialog volumedialog = new Dialog(); - volumedialog.Show(); - //鐖舵帶浠� - FrameLayout frame = new FrameLayout { }; - volumedialog.AddChidren(frame); - //鐧借壊蹇埗鎺т欢 - FrameLayout dialogFra = new FrameLayout() - { - X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(397-20), - Width = Application.GetRealWidth(344), - Height = Application.GetRealHeight(250+20), - BackgroundColor = MusicColor.WhiteColor, - Radius = (uint)Application.GetRealHeight(12), - }; - frame.AddChidren(dialogFra); - #region 纭 鍙栨秷 - //鏄剧ず澶撮儴淇℃伅鐖舵帶浠� - FrameLayout topFra = new FrameLayout() - { - Width = Application.GetRealWidth(344), - Height = Application.GetRealHeight(58), - }; - dialogFra.AddChidren(topFra); - //鍙栨秷鎺т欢 - Button cancelnBtn = new Button - { - X = Application.GetRealWidth(20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(60), - Height = Application.GetRealHeight(20), - TextID = StringId.cancelMusic, - TextAlignment = TextAlignment.CenterLeft, - TextColor = MusicColor.MusicNoTxetColor, - TextSize = TextSize.Text14, - }; - topFra.AddChidren(cancelnBtn); - //鏍囬鎺т欢 - Button txetBtn = new Button - { - X = cancelnBtn.Right + Application.GetRealWidth(20), - Y = Application.GetRealHeight(14), - Width = Application.GetRealWidth(152), - Height = Application.GetRealHeight(22), - TextColor = MusicColor.TextColor, - TextSize = TextSize.Text16, - TextAlignment = TextAlignment.Center, - TextID = StringId.volumeAdjustment, - IsBold = true, - }; - topFra.AddChidren(txetBtn); - //纭鎺т欢 - Button confirmBtn = new Button - { - X = Application.GetRealWidth(344 - 60 - 20), - Y = Application.GetRealHeight(15), - Width = Application.GetRealWidth(60), - Height = Application.GetRealHeight(20), - TextID = StringId.confirmMusic, - TextAlignment = TextAlignment.CenterRight, - TextColor = MusicColor.SelectedColor, - TextSize = TextSize.Text14, - }; - topFra.AddChidren(confirmBtn); - - EventHandler<MouseEventArgs> eventHandler= (sen,e) => { - volumedialog.Close(); - if (updateVolumeThread != null) - { - try - { - if (updateVolumeThread.IsAlive) - { - updateVolumeThread.Abort(); - } - } - catch { } - } - }; - cancelnBtn.MouseUpEventHandler += eventHandler; - confirmBtn.MouseUpEventHandler += eventHandler; - frame.MouseUpEventHandler += eventHandler; - #endregion - #region 鎬婚煶閲忕殑View - FrameLayout totalVolumeFra = new FrameLayout - { - Height = Application.GetRealHeight(64), - Y = Application.GetRealHeight(58), - }; - dialogFra.AddChidren(totalVolumeFra); - Button totalvolumeTextBtn = new Button - { - X = Application.GetRealWidth(28), - Y = Application.GetRealHeight(8), - Width = Application.GetRealWidth(200), - Height = Application.GetRealHeight(14), - TextColor = MusicColor.MusicNoTxetColor, - TextSize = TextSize.Text10, - TextAlignment = TextAlignment.CenterLeft, - Text = Language.StringByID(StringId.totalVolume), - }; - totalVolumeFra.AddChidren(totalvolumeTextBtn); - DiyImageSeekBar totalVolSeekBar = new DiyImageSeekBar - { - Y = Application.GetRealHeight(12), - X = Application.GetRealWidth(28), - Width = Application.GetRealWidth(240), - Height = Application.GetRealHeight(54),//杩涘害鏉$埗鎺т欢鑳屾櫙楂樺害 - IsProgressTextShow = false,//鏄剧ず鐧惧垎姣� - IsClickable = true,//杩涘害鏉℃槸鍚︽粦鍔� - ProgressBarColor = MusicColor.SelectedColor,//閫変腑杩涘害鏉¢鑹� - ThumbImagePath = "MusicIcon/progressIcon.png",//杩涘害鏉℃寜閽浘鏍� - ThumbImageHeight = Application.GetRealWidth(54),//杩涘害鏉℃寜閽浘鏍囩殑楂樺害锛堥粯璁ゆ鏂瑰舰锛氬鍜岄珮涓�鏍凤級 - SeekBarViewHeight = Application.GetRealWidth(8),//杩涘害鏉$殑楂樺害 - Progress = int.Parse(a31player.A31PlayStatus.vol), - SeekBarPadding = Application.GetRealWidth(20), - //ProgressChangeDelayTime= - }; - totalVolumeFra.AddChidren(totalVolSeekBar); - - Button totalVolumeValueBtn = new Button - { - X = Application.GetRealWidth(289), - Y = Application.GetRealHeight(31), - Width = Application.GetRealWidth(26 + 15), - Height = Application.GetRealHeight(17), - TextColor = MusicColor.MusicNoTxetColor, - TextSize = TextSize.Text12, - TextAlignment = TextAlignment.CenterLeft, - Text = totalVolSeekBar.Progress.ToString() + "%", - }; - totalVolumeFra.AddChidren(totalVolumeValueBtn); - #endregion - - VerticalScrolViewLayout volumeViewLayout = new VerticalScrolViewLayout - { - Y =Application.GetRealHeight(58+64), - Height = dialogFra.Height - Application.GetRealHeight(58+64), - Width = Application.GetRealWidth(343), - }; - dialogFra.AddChidren(volumeViewLayout); - - for (int i = 0; i < volumePlayList.Count; i++) - { - var player = volumePlayList[i]; - #region 璋冭妭褰撲釜鎾斁鍣╒iew - FrameLayout volumeFra = new FrameLayout - { - Height = Application.GetRealHeight(64), - }; - volumeViewLayout.AddChidren(volumeFra); - Button volumeTextBtn = new Button - { - X = Application.GetRealWidth(28), - Y = Application.GetRealHeight(8), - Width = Application.GetRealWidth(200), - Height = Application.GetRealHeight(14), - TextColor = MusicColor.MusicNoTxetColor, - TextSize = TextSize.Text10, - TextAlignment = TextAlignment.CenterLeft, - Text = player.Name + Language.StringByID(StringId.volumeMusic), - - }; - volumeFra.AddChidren(volumeTextBtn); - - DiyImageSeekBar volSeekBar = new DiyImageSeekBar - { - Y = Application.GetRealHeight(12), - X = Application.GetRealWidth(28), - Width = Application.GetRealWidth(240), - Height = Application.GetRealHeight(54),//杩涘害鏉$埗鎺т欢鑳屾櫙楂樺害 - IsProgressTextShow = false,//鏄剧ず鐧惧垎姣� - IsClickable = true,//杩涘害鏉℃槸鍚︽粦鍔� - ProgressBarColor = MusicColor.SelectedColor,//閫変腑杩涘害鏉¢鑹� - ThumbImagePath = "MusicIcon/progressIcon.png",//杩涘害鏉℃寜閽浘鏍� - ThumbImageHeight = Application.GetRealWidth(54),//杩涘害鏉℃寜閽浘鏍囩殑楂樺害锛堥粯璁ゆ鏂瑰舰锛氬鍜岄珮涓�鏍凤級 - SeekBarViewHeight = Application.GetRealWidth(8),//杩涘害鏉$殑楂樺害 - Progress = int.Parse(player.A31PlayStatus.vol), - SeekBarPadding = Application.GetRealWidth(20), - //ProgressChangeDelayTime= - }; - volumeFra.AddChidren(volSeekBar); - - Button valueBtn = new Button - { - X = Application.GetRealWidth(289), - Y = Application.GetRealHeight(31), - Width = Application.GetRealWidth(26+15), - Height = Application.GetRealHeight(17), - TextColor = MusicColor.MusicNoTxetColor, - TextSize = TextSize.Text12, - TextAlignment = TextAlignment.CenterLeft, - Text = player.A31PlayStatus.vol + "%", - }; - volumeFra.AddChidren(valueBtn); - #endregion - ///闊抽噺杩涘害鏉$偣鍑讳簨浠� - EventHandler<int> progressClick = (sender, e) => - { - if (currVolumePlay == null || (currVolumePlay != null && currVolumePlay.UniqueDeviceName != player.UniqueDeviceName)) - { - currVolumePlay = player; - } - endVolume = e; - if_volume = "Volume"; - valueBtn.Text = volSeekBar.Progress + "%"; - }; - volSeekBar.OnProgressChangedEvent += progressClick; - volSeekBar.OnStopTrackingTouchEvent += progressClick; - } - - EventHandler<int> totalProgressClick = (sender, e) => - { - if_volume = "totalVolume"; - endVolume = e; - totalVolumeValueBtn.Text = totalVolSeekBar.Progress + "%"; - for (int j = 0; j < volumePlayList.Count; j++) - { - var music = volumePlayList[j]; - var frameLayout = (FrameLayout)volumeViewLayout.GetChildren(j); - var diyImageSeekBar = (DiyImageSeekBar)frameLayout.GetChildren(1); - var button = (Button)frameLayout.GetChildren(2); - diyImageSeekBar.Progress = totalVolSeekBar.Progress; - button.Text = totalVolSeekBar.Progress + "%"; - } - }; - totalVolSeekBar.OnProgressChangedEvent += totalProgressClick; - totalVolSeekBar.OnStopTrackingTouchEvent += totalProgressClick; - #endregion - - } - /// <summary> - /// 瀹氭椂闊抽噺骞朵笖鍙戦�佸懡浠� - /// </summary> - System.Threading.Thread updateVolumeThread; - public void UpdateVolume() - { - if (updateVolumeThread != null) { - try - { - if (updateVolumeThread.IsAlive) { - updateVolumeThread.Abort(); - } - } - catch { } - } - updateVolumeThread = new System.Threading.Thread(() => - { - try - { - while (true) - { - System.Threading.Thread.Sleep(500); - if (startVolume == endVolume) - { - continue; - } - startVolume = endVolume; - if (if_volume == "totalVolume") - { - for (int j = 0; j < volumePlayList.Count; j++) - { - var music = volumePlayList[j]; - //姣忎釜500姣鍙戜粠鎾斁鍣ㄩ煶閲忓懡浠� - SendMethod.ControlVolume(endVolume, music); - System.Threading.Thread.Sleep(1000); - - } - } - else if(if_volume == "Volume") - { - if (currVolumePlay == null) - { - continue; - } - SendMethod.ControlVolume(endVolume, currVolumePlay); - } - - - } - } - catch { } - }) - { IsBackground = true }; - updateVolumeThread.Start(); } } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/View/MusicView.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/View/MusicView.cs index 1dfd44f..9f1e81c 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/View/MusicView.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/View/MusicView.cs @@ -10,14 +10,17 @@ /// </summary> public FrameLayout muiscFl = new FrameLayout { + Name= "parentfl", Height = Application.GetRealHeight(12 + 139), Width = Application.GetRealWidth(375), + }; /// <summary> ///鐧借壊鑳屾櫙鐨勬帶浠� /// </summary> public FrameLayout musicIfonFl = new FrameLayout { + Name = "musicparentfl", X = Application.GetRealWidth(16), Y = Application.GetRealHeight(12), Height = Application.GetRealHeight(139), @@ -89,6 +92,7 @@ /// </summary> public Button songNameBtn = new Button { + Name="song", X = Application.GetRealWidth(54), Y = Application.GetRealHeight(12), Width = Application.GetRealWidth(140), @@ -102,6 +106,7 @@ /// </summary> public Button singerBtn = new Button { + Name= "singer", X = Application.GetRealWidth(54), Y = Application.GetRealHeight(36), Width = Application.GetRealWidth(120), @@ -116,6 +121,7 @@ /// </summary> public Button musicNameBtn = new Button { + Name = "musicname", X = Application.GetRealWidth(54), Y = Application.GetRealHeight(40),//58 Width = Application.GetRealWidth(140), @@ -166,6 +172,7 @@ /// </summary> public Button playBtn = new Button { + Tag= "playstatus", X = Application.GetRealWidth(233), Y = Application.GetRealHeight(101), Width = Application.GetRealWidth(32), @@ -189,14 +196,14 @@ /// 鎾斁鍣ㄧ晫闈㈢殑鏂规硶 /// </summary> /// <param name="verticalRefresh"></param> - public void View(VerticalRefreshLayout verticalRefresh) + public void ViewAddChidren(VerticalRefreshLayout verticalRefresh) { verticalRefresh.AddChidren(muiscFl); muiscFl.AddChidren(musicIfonFl); musicIfonFl.AddChidren(iconBtn); - musicIfonFl.AddChidren(mergeBjBtn); - musicIfonFl.AddChidren(mergeIconBtn); - musicIfonFl.AddChidren(mergeBtn); + //musicIfonFl.AddChidren(mergeBjBtn); + //musicIfonFl.AddChidren(mergeIconBtn); + //musicIfonFl.AddChidren(mergeBtn); musicIfonFl.AddChidren(collectIconBtn); musicIfonFl.AddChidren(songNameBtn); //musicIfonFl.AddChidren(singerBtn); diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/View/MyListView.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/View/MyListView.cs index c9b4aab..86bf14f 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/View/MyListView.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/View/MyListView.cs @@ -91,20 +91,21 @@ }; public void frameLayout(FrameLayout frame,A31MusicModel a31MusicModel) { - switch (a31MusicModel.A31PlayStatus.loop) + var mode= a31MusicModel.functionMusic.GetAttrState("mode"); + switch (mode) { //0鍒楄〃寰幆锛�1鍗曟洸寰幆锛�2闅忔満鎾斁; - case "0": + case "list_cycle": orderIconBtn.UnSelectedImagePath = "MusicIcon/list.png"; orderTxetBtn.Text = Language.StringByID(StringId.listMode); break; - case "1": + case "single_cycle/order": orderIconBtn.UnSelectedImagePath = "MusicIcon/single.png"; orderTxetBtn.Text = Language.StringByID(StringId.singleMode); break; - case "2": + case "random": orderIconBtn.UnSelectedImagePath = "MusicIcon/random.png"; orderTxetBtn.Text = Language.StringByID(StringId.randomMode); break; diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/View/PlayView.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/View/PlayView.cs index b054490..9c9b11a 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/View/PlayView.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/View/PlayView.cs @@ -14,6 +14,8 @@ Height = Application.GetRealHeight(526), Width = Application.GetRealWidth(327), BackgroundImagePath = "MusicIcon/playBj.png", + Name="fl", + }; /// <summary> /// 闊充箰姹夊瓧 @@ -28,6 +30,7 @@ TextSize = TextSize.Text24, TextAlignment = TextAlignment.CenterLeft, TextID = StringId.a31Music, + Name = "musicname" }; /// <summary> /// 鍖哄煙鍚嶇О @@ -41,6 +44,7 @@ TextColor = MusicColor.MusicNoTxetColor, TextSize = TextSize.Text12, TextAlignment = TextAlignment.CenterLeft, + Name= "region", }; /// <summary> ///鏀惰棌鍥炬爣 @@ -53,6 +57,7 @@ Height = Application.GetRealWidth(40), UnSelectedImagePath = "MusicIcon/collect.png", SelectedImagePath = "MusicIcon/collectSelected.png", + Name = "collect" }; /// <summary> ///蹇�,閫�杩涘害鏉$埗鎺т欢 @@ -86,11 +91,13 @@ ArcWidth = Application.GetRealWidth(4),//杩涘害瀹藉害 ThumbImagePath = "MusicIcon/thumbImage.png",//杩涘害鏉℃寜閽浘鏍� ThumbImageHeight = Application.GetMinRealAverage(8),//杩涘害鏉℃寜閽浘鏍囩殑楂樺害锛堥粯璁ゆ鏂瑰舰锛氬鍜岄珮涓�鏍凤級 - MaxValue=100, + MaxValue = 100, Gravity = Gravity.Center, SeekBarPadding = Application.GetMinRealAverage(3), + IsClickable = false,//涓嶅彲浠ユ粦鍔� + }; - + /// <summary> ///闊充箰寮�濮嬫椂闂� /// </summary> @@ -207,6 +214,7 @@ SeekBarViewHeight = Application.GetRealWidth(8),//杩涘害鏉$殑楂樺害 ProgressChangeDelayTime = 300,//0.3绉掑彂閫佷竴娆� SeekBarPadding = Application.GetRealWidth(20), + }; /// <summary> @@ -264,6 +272,7 @@ /// <param name="fL"></param> public void viewFrameLayout(FrameLayout fL) { + fL.AddChidren(musicBjFl); musicBjFl.AddChidren(musicNameBtn); musicBjFl.AddChidren(regionBtn); diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/View/SongView.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/View/SongView.cs index cc67593..26b9e2f 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/View/SongView.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/View/SongView.cs @@ -94,39 +94,30 @@ /// 甯冨眬姝屾洸淇℃伅鐨刅iew /// </summary> /// <returns></returns> - public void SongFrameLayout(VerticalRefreshLayout refreshLayout, MusicInfo songs) + public void SongFrameLayout(VerticalRefreshLayout refreshLayout, Songs songs) { musicViewFl.AddChidren(playIconBtn); musicViewFl.AddChidren(songBtn); - musicViewFl.AddChidren(singerBtn); + //musicViewFl.AddChidren(singerBtn); musicViewFl.AddChidren(clickBtn); - musicViewFl.AddChidren(loveIcon); - musicViewFl.AddChidren(addIcon); + //musicViewFl.AddChidren(loveIcon); + //musicViewFl.AddChidren(addIcon); refreshLayout.AddChidren(musicViewFl); playIconBtn.Tag = songs.URL; - songBtn.Tag = songs.URL; - singerBtn.Tag = songs.URL; + songBtn.Tag = songs.name; + singerBtn.Tag = songs.name; clickBtn.Tag = songs;//鏍囪鎾斁鍝竴棣栨瓕鏇� - songBtn.Text = string.IsNullOrEmpty(songs.Title) ? "Unkonw" : songs.Title.Trim(); + songBtn.Text = string.IsNullOrEmpty(songs.name) ? "Unkonw" : songs.name.Trim(); var wText = songBtn.GetTextWidth() + Application.GetRealWidth(15); - if (wText > Application.GetRealWidth(220)) + if (wText > Application.GetRealWidth(250)) { - wText = Application.GetRealWidth(220);//(姝屾洸+姝屾墜)瀹藉害鏈�澶у�兼椂220 + wText = Application.GetRealWidth(250);//(姝屾洸+姝屾墜)瀹藉害鏈�澶у�兼椂220 } songBtn.Width = wText; singerBtn.X = songBtn.Right; singerBtn.Width = Application.GetRealWidth(220) - wText;//姝屽悕闀垮害灏忎簬220鎵嶅彲浠ユ樉绀烘瓕鎵嬪嚭鏉� - singerBtn.Text = string.IsNullOrEmpty(songs.Artist) ? "-Unkonw" : "-" + songs.Artist.Trim(); - var music = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL); - if (music != null) - { - loveIcon.IsSelected = true; - } - else - { - loveIcon.IsSelected = false; - } + singerBtn.Text = string.IsNullOrEmpty(songs.name) ? "-Unkonw" : "-" + songs.name.Trim(); } -- Gitblit v1.8.0