From 52c945d6f5628e7fac328a5df8bc295ccfc5966b Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期一, 10 一月 2022 20:53:54 +0800 Subject: [PATCH] 2021-1-10-01 --- HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs | 2 HDL_ON/UI/UI2/1-HomePage/HomePage.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/View/PlayView.cs | 8 HDL_ON/Common/ApiUtlis.cs | 2 HDL_ON/UI/UI2/FuntionControlView/Music/MusicProperty.cs | 141 ++ HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs | 182 -- HDL_ON/UI/UI2/FuntionControlView/Music/View/DialogView.cs | 1235 -------------------- HDL_ON/HDL_ON.projitems | 9 HDL_ON/UI/UI2/FuntionControlView/Music/A31SongPlay.cs | 74 + HDL_ON/UI/UI2/FuntionControlView/Music/A31MyListMusic.cs | 4 HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs | 941 -------------- /dev/null | 200 --- HDL_ON/UI/UI2/FuntionControlView/Music/View/SongView.cs | 29 HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicSourcePage.cs | 178 -- HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs | 195 +- HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicFileList.cs | 6 HDL_ON/UI/UI2/FuntionControlView/Music/View/MusicView.cs | 15 HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs | 2 HDL_ON/DAL/DriverLayer/Control.cs | 20 HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs | 6 HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs | 280 ++- 23 files changed, 629 insertions(+), 2,988 deletions(-) diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs index 5ef087c..a863055 100644 --- a/HDL_ON/Common/ApiUtlis.cs +++ b/HDL_ON/Common/ApiUtlis.cs @@ -369,8 +369,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 4a6ad64..33ea1fa 100644 --- a/HDL_ON/DAL/DriverLayer/Control.cs +++ b/HDL_ON/DAL/DriverLayer/Control.cs @@ -976,17 +976,29 @@ } 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); + } //鏇存柊鐣岄潰鐘舵�� @@ -1167,6 +1179,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/HDL_ON.projitems b/HDL_ON/HDL_ON.projitems index df27706..8ff767a 100644 --- a/HDL_ON/HDL_ON.projitems +++ b/HDL_ON/HDL_ON.projitems @@ -464,19 +464,11 @@ <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\3-Intelligence\Automation\CalculatedDistance.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\ArmCenter\PushConfigPage.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" /> @@ -490,6 +482,7 @@ <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/UI2/1-HomePage/HomePage.cs b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs index 477f128..bb0d6af 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs @@ -1173,7 +1173,7 @@ function.SetAttrState("on_off", status); Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("on_off", status); - Music.SendMethod.sendMethod.SendControlCommand(function, dic); + Music.SendMethod.mMethod.SendControlCommand(function, dic); }; } diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs b/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs index ade6e01..ede9b51 100644 --- a/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs @@ -219,7 +219,7 @@ m.functionMusic.SetAttrState("on_off", "off"); Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("on_off", "off"); - Music.SendMethod.sendMethod.SendControlCommand(m.functionMusic, dic); + Music.SendMethod.mMethod.SendControlCommand(m.functionMusic, dic); } } }) diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs b/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs index e4a3f68..3b8ac47 100644 --- a/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs @@ -302,7 +302,7 @@ a31player.SetAttrState("song_step", "up"); Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("song_step", "up"); - SendMethod.sendMethod.SendControlCommand(a31player, dic); + SendMethod.mMethod.SendControlCommand(a31player, dic); }; btnPrev.MouseUpEventHandler = (sender, e) => { @@ -325,7 +325,7 @@ a31player.SetAttrState("on_off", status); Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("on_off", status); - SendMethod.sendMethod.SendControlCommand(a31player, dic); + SendMethod.mMethod.SendControlCommand(a31player, dic); }; ///涓嬩竴鏇茬偣鍑讳簨浠� btnNext.MouseDownEventHandler = (sender, e) => @@ -334,7 +334,7 @@ a31player.SetAttrState("song_step", "down"); Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("song_step", "down"); - SendMethod.sendMethod.SendControlCommand(a31player, dic); + 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 6bbfd24..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.MusicIxnfoList, A31MusicModel.Current); - } - /// <summary> - /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 - /// </summary> - public void UpdateSelectedMusic() - { - UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(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 3d7c891..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 c7189cb..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.PlayMusicClick(middViewLayout, "鎴戠殑鏈�鐖�", listName, A31MusicModel.Current.LoveMusicInfoList); + //UpdateThread.PlayMusicClick(middViewLayout, "鎴戠殑鏈�鐖�", listName, A31MusicModel.Current.LoveMusicInfoList); } /// <summary> /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 /// </summary> public void UpdateSelectedMusic() { - UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(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 index 96b11c8..2982d04 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicFileList.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicFileList.cs @@ -17,7 +17,7 @@ this.BackgroundColor = MusicColor.ViewColor; var topView = new TopView(); this.AddChidren(topView.TopFLayoutView()); - topView.topNameBtn.TextID = StringId.usb; + topView.topNameBtn.TextID = StringId.localMusic; topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); @@ -37,14 +37,14 @@ { try { - SendMethod.sendMethod.GetPalyList(A31MusicModel.Current.functionMusic); + SendMethod.mMethod.GetPalyList(A31MusicModel.Current.functionMusic); } catch { } finally { Application.RunOnMainThread(() => { - FileView(); + this.FileView(); middViewLayout.EndHeaderRefreshing(); }); } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs index 52b7c03..16da59d 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs @@ -16,83 +16,13 @@ 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 Function functionMusic = new Function(); - /// <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].functionMusic.collect) - { - return true; //鏌ヨ鏄惁鏈夐煶涔愯鏀惰棌杩� - } - } - return false; - } - } + + /// <summary> ///淇濆瓨褰撳墠闊充箰鍒楄〃 /// </summary> @@ -120,44 +50,20 @@ 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(); @@ -193,33 +99,6 @@ public List<Songs> dlnaMusicInfoLists = new List<Songs>(); /// <summary> - /// 鐢靛彴鎵�鏈夊垪琛� - /// </summary> - public List<Songs> CnRadioInfoList = new List<Songs>(); - - /// <summary> - /// vTuner鐢靛彴鎵�鏈夊垪琛� - /// </summary> - public List<Songs> vTunerList = new List<Songs>(); - - /// <summary> - /// 鍠滅埍鐢靛彴鍒楄〃 - /// </summary> - public List<Songs> LoveRadioInfoList = new List<Songs>(); - - /// <summary> - /// Pandora鐢靛彴鎵�鏈夊垪琛� - /// </summary> - public List<Songs> PanRadioInfoList = new List<Songs>(); - /// <summary> - /// usb鍒楄〃 - /// </summary> - public List<Songs> USBList = new List<Songs>(); - /// <summary> - /// Tidal鍠滅埍鍒楄〃 - /// </summary> - public List<Songs> TidalLikelist = new List<Songs>(); - /// <summary> ///鍒涘缓闊充箰鏂囦欢鍒楄〃 /// </summary> public List<FileListInfo> FileLists = new List<FileListInfo>(); @@ -228,49 +107,9 @@ /// </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 - { - get - { - return _MainPlayName; - } - set - { - _MainPlayName = value; - //if(ServerClientType == 1) - //{ - // name = value; - //} - } - } /// <summary> /// 鎸囧畾鍒楄〃鍚嶈幏鍙栭煶涔愬垪琛� /// </summary> @@ -294,6 +133,11 @@ /// </summary> public static DateTime ProgressDateTime = DateTime.Now; + /// <summary> + /// 鍒ゆ柇鏄惁鏄痡son鏁版嵁 + /// </summary> + /// <param name="json"></param> + /// <returns></returns> public static bool IsJson(string json) { try diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicSourcePage.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicSourcePage.cs index bf32937..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); @@ -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); @@ -124,36 +118,14 @@ View.MusicSourceView musicSourceView = new View.MusicSourceView(); musicSourceView.fLayout.Y = selectedSourceView.fLayout.Bottom; - musicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/usb.png"; - musicSourceView.textBtn.TextID = StringId.usb; + musicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/localMusic.png"; + musicSourceView.textBtn.TextID = StringId.localMusic; musicSourceView.FrameLayoutView(fL3); - View.MusicSourceView localMusicSourceView = new View.MusicSourceView(); - localMusicSourceView.fLayout.Y = musicSourceView.fLayout.Bottom; - localMusicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/localMusic.png"; - localMusicSourceView.textBtn.TextID = StringId.localMusic; - //localMusicSourceView.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); @@ -186,7 +158,7 @@ { if (A31MusicModel.Current.palyLists.Count == 0) { - SendMethod.sendMethod.GetPalyList(A31MusicModel.Current.functionMusic); + SendMethod.mMethod.GetPalyList(A31MusicModel.Current.functionMusic); } } @@ -208,25 +180,25 @@ ///鎾斁鍣ㄤ慨鏀瑰悕绉颁簨浠� 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) => { @@ -264,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 21a2aa7..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 a673650..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.PlayMusicClick(middViewLayout,"鎴戠殑鍒楄〃", fileListInfo.ListName, fileListInfo.MusicInfoList); + // A31SongPlay.SongListView(middViewLayout,fileListInfo.ListName, fileListInfo.MusicInfoList); } /// <summary> /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 /// </summary> public void UpdateSelectedMusic() { - UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(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 5a8636c..855e266 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31PlayMusicPage.cs @@ -3,6 +3,7 @@ using com.hdl.on; using System.Collections.Generic; using System.Security; +using HDL_ON.UI.UI2.FuntionControlView.Music; namespace HDL_ON.UI.Music { @@ -36,17 +37,18 @@ /// new甯冨眬鐣岄潰 /// </summary> View.PlayView playView = new View.PlayView(); - + TopView topView; + + public void Show() { ///1绉掑畾鏃舵洿鏂扮姸鎬� timerUpdateStatus(); #region ---鐣岄潰甯冨眬--- this.BackgroundColor = MusicColor.ViewColor; - var topView = new TopView(); + topView = new TopView(); topView.setBtn.Visible = true; this.AddChidren(topView.TopFLayoutView()); - topView.topNameBtn.Text = A31MusicModel.Current.Name; topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); @@ -82,52 +84,36 @@ } }; - //蹇繘婊戝姩寮硅捣浜嬩欢; - playView.diyArcSeekBar.OnStopTrackingTouchEvent+= (sender, e) => - { - //int totalSecond = (int)(playView.diyArcSeekBar.Progress * 1.0f / 100 * int.Parse(A31MusicModel.Current.functionMusic.GetAttrState("song_time"))); - ////鍒嗛挓 - //int Minute = totalSecond / 60; - ////绉掗挓 - //int Second = totalSecond % 60; - //string time = "00" + ":" + (Minute.ToString().Length < 2 ? "0" + Minute.ToString() : Minute.ToString()) + ":" + (Second.ToString().Length < 2 ? "0" + Second.ToString() : Second.ToString()); - //SendMethod.Seek(time, A31MusicModel.Current); - - //Dictionary<string, string> dic = new Dictionary<string, string>(); - //dic.Add("mode", modeValueString); - //SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); - // A31MusicModel.Current.A31PlayStatus.curpos = (DateTime.Parse(time) - DateTime.Parse("00:00:00")).TotalMilliseconds.ToString(); - }; ///鍒囨崲鎾斁妯″紡鐐瑰嚮浜嬩欢; playView.playOrderBtn.MouseUpEventHandler += (sender, e) => { string modeValueString = string.Empty; string msg = Language.StringByID(StringId.switchTo); - switch (A31MusicModel.Current.A31PlayStatus.loop) + switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode)) { //list_cycle鍒楄〃寰幆锛宻ingle_cycle鍗曟洸寰幆锛宺andom闅忔満鎾斁; - case "list_cycle": - modeValueString="single_cycle"; + case ValueProperty.list_cycle: + modeValueString=ValueProperty.single_cycle; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; msg += Language.StringByID(StringId.singleMode); break; - case "single_cycle": - modeValueString = "random"; + case ValueProperty.single_cycle: + modeValueString =ValueProperty.random; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; msg += Language.StringByID(StringId.randomMode); break; - case "random": - modeValueString = "list_cycle"; + case ValueProperty.random: + modeValueString = ValueProperty.list_cycle; playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; msg += Language.StringByID(StringId.listMode); break; } - A31MusicModel.Current.functionMusic.SetAttrState("mode", modeValueString); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.mode, modeValueString); new PublicAssmebly().TipMsgAutoClose(msg, false,1000); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("mode",modeValueString); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic,dic); + dic.Add(KeyProperty.mode,modeValueString); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic,dic); }; ///娣诲姞鍠滅埍鐐瑰嚮浜嬩欢; playView.loveBtn.MouseUpEventHandler += (sender, e) => @@ -135,49 +121,24 @@ var name = A31MusicModel.Current.functionMusic.GetAttribute("song_name").ToString(); var songTime = A31MusicModel.Current.functionMusic.GetAttribute("song_time").ToString(); - if (A31MusicModel.Current.A31PlayStatus.Source == "RADIO-NETWORK") + playView.loveBtn.IsSelected = !playView.loveBtn.IsSelected; + if (playView.loveBtn.IsSelected) { - playView.loveBtn.IsSelected = !playView.loveBtn.IsSelected; - if (playView.loveBtn.IsSelected) + if (null == A31MusicModel.Current.LoveMusicInfoList.Find((musicInfo) => { - if (null == A31MusicModel.Current.LoveRadioInfoList.Find((musicInfo) => - { - return name == musicInfo.name; - })) - { - A31MusicModel.Current.LoveRadioInfoList.Add(new Songs { name = name, time = songTime}); - } - } - else + return name == musicInfo.name; + })) { - A31MusicModel.Current.LoveRadioInfoList.RemoveAll((musicInfo) => - { - return name == musicInfo.name; - }); + A31MusicModel.Current.LoveMusicInfoList.Add(new Songs { name = name, time = songTime }); } } else { - playView.loveBtn.IsSelected = !playView.loveBtn.IsSelected; - if (playView.loveBtn.IsSelected) + A31MusicModel.Current.LoveMusicInfoList.RemoveAll((musicInfo) => { - if (null == A31MusicModel.Current.LoveMusicInfoList.Find((musicInfo) => - { - return name == musicInfo.name; - })) - { - A31MusicModel.Current.LoveMusicInfoList.Add(new Songs { name = name, time = songTime}); - } - } - else - { - A31MusicModel.Current.LoveMusicInfoList.RemoveAll((musicInfo) => - { - //涔熻鍔犳瓕鎵嬪悕鍒ゆ柇 - return musicInfo.name == name; - }); - } - + //涔熻鍔犳瓕鎵嬪悕鍒ゆ柇 + return musicInfo.name == name; + }); } A31MusicModel.Save(); }; @@ -214,13 +175,7 @@ ///闊抽噺鍥炬爣鐐瑰嚮浜嬩欢 playView.volIconBtn.MouseUpEventHandler += (sender, e) => { - if (A31MusicModel.Current.ServerClientType == 1 && A31MusicModel.Current.Slave.slave_list.Count != 0) - { ///涓绘挱鏀惧櫒 - var volumeView = new View.DialogView { }; - volumeView.PlayerVolumeView(A31MusicModel.Current); - volumeView.UpdateVolume(); - - } + }; ///闊抽噺杩涘害鏉$偣鍑讳簨浠� int startVolume =0;//涔嬪墠鐨勯煶閲� @@ -231,10 +186,10 @@ if (startVolume != e) { startVolume = e; - A31MusicModel.Current.functionMusic.SetAttrState("volume", startVolume); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("volume", startVolume.ToString()); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + dic.Add(KeyProperty.volume, startVolume.ToString()); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); } }; @@ -245,10 +200,10 @@ { playView.prevBtn.IsSelected = true; - A31MusicModel.Current.functionMusic.SetAttrState("song_step", "down"); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step,ValueProperty.down); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("song_step", "down"); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + dic.Add(KeyProperty.song_step, ValueProperty.down); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; playView.prevBtn.MouseUpEventHandler += (sender, e) => @@ -262,26 +217,26 @@ if (playView.playBtn.IsSelected) { playView.playBtn.IsSelected = false; - status = "off"; + status = ValueProperty.off; } else { playView.playBtn.IsSelected = true; - status = "on"; + status = ValueProperty.on; } - A31MusicModel.Current.functionMusic.SetAttrState("on_off", status); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.on_off, status); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("on_off", status); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + dic.Add(KeyProperty.on_off, status); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; ///涓嬩竴鏇茬偣鍑讳簨浠� playView.nextBtn.MouseDownEventHandler += (sender, e) => { playView.nextBtn.IsSelected = true; - A31MusicModel.Current.functionMusic.SetAttrState("song_step", "down"); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.song_step,ValueProperty.down); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("song_step", "down"); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + dic.Add(KeyProperty.song_step, ValueProperty.down); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }; playView.nextBtn.MouseUpEventHandler += (sender, e) => { @@ -290,7 +245,7 @@ ///鐗╃悊鎸夐敭鐨勭偣鍑讳簨浠� Volume.VolumeChange = (volume) => { - if (Application.DeviceType == Device.Ios && A31MusicModel.Current.A31PlayStatus.Source == "BLUETOOTH") + if (Application.DeviceType == Device.Ios && A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.source) == "bluetooth") { return; } @@ -299,10 +254,10 @@ if (startVolume != volume) { startVolume = volume; - A31MusicModel.Current.functionMusic.SetAttrState("volume", startVolume); + A31MusicModel.Current.functionMusic.SetAttrState(KeyProperty.volume, startVolume); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("volume", startVolume.ToString()); - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + dic.Add(KeyProperty.volume, startVolume.ToString()); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); } }; @@ -325,10 +280,9 @@ { try { - //鏇存柊鎬绘椂闂� //鎬诲叡鏈夊灏戠 - int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState("song_time")); + int totalSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_time))/1000; //鍒嗛挓 int totalMusicMinute = totalSecond / 60; //绉掗挓 @@ -337,17 +291,17 @@ string totalTime = (totalMusicMinute.ToString().Length < 2 ? "0" + totalMusicMinute.ToString() : totalMusicMinute.ToString()) + ":" + (totalMusicSecond.ToString().Length < 2 ? "0" + totalMusicSecond.ToString() : totalMusicSecond.ToString()); playView.endTimeBtn.Text = totalTime; - //topView.topNameBtn.Text = A31MusicModel.Current.Name; + topView.topNameBtn.Text = A31MusicModel.Current.functionMusic.name; - switch (A31MusicModel.Current.functionMusic.GetAttrState("mode")) + switch (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.mode)) { - case "list_cycle"://鍒楄〃寰幆 + case ValueProperty.list_cycle://鍒楄〃寰幆 playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/list.png"; break; - case "single_cycle"://鍗曟洸寰幆 + case ValueProperty.single_cycle://鍗曟洸寰幆 playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/single.png"; break; - case "random"://闅忔満鎾斁 + case ValueProperty.random://闅忔満鎾斁 playView.playOrderBtn.UnSelectedImagePath = "MusicIcon/random.png"; break; } @@ -412,15 +366,15 @@ if (1000 < (DateTime.Now - A31MusicModel.ProgressDateTime).TotalMilliseconds) { //闊抽噺杩涘害鏉�; - playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.A31PlayStatus.vol); + playView.volSeekBar.Progress = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume)); //鏄剧ず褰撳墠闊抽噺鍊�; - playView.volValueBtn.Text = A31MusicModel.Current.A31PlayStatus.vol + "%"; + playView.volValueBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.volume) + "%"; } //鏇存柊鎾斁鍣ㄩ煶閲忕粰绯荤粺闊抽噺 Volume.MusicVolume = playView.volSeekBar.Progress; //褰撳墠鎾斁闊充箰鏃堕棿 //鎸夐亾鐞嗕笉浼氫负绌猴紝GetAttrState("playing_time")鍊煎彲鑳戒负绌猴紝寮哄埗杞崲int.Parse(锛変細鍑虹幇寮傚父锛屼笉杩囦篃鍋氫簡寮傚父澶勭悊浜� - int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState("playing_time"))+ (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; + int playSecond = int.Parse(A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playing_time))/1000+ (int)(DateTime.Now - A31MusicModel.Current.LastDateTime).TotalSeconds; int playMusicMinute = playSecond / 60; //绉掗挓 @@ -428,7 +382,7 @@ string playTime = (playMusicMinute.ToString().Length < 2 ? "0" + playMusicMinute.ToString() : playMusicMinute.ToString()) + ":" + (playMusicSecond.ToString().Length < 2 ? "0" + playMusicSecond.ToString() : playMusicSecond.ToString()); - if (A31MusicModel.Current.functionMusic.GetAttrState("on_off") == "on") + if (A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on) { playView.playBtn.IsSelected = true; //濡傛灉鍦ㄦ挱鏀撅紝鏃堕棿灏变笉鏂彉鍖� @@ -444,6 +398,8 @@ playView.diyArcSeekBar.Progress = (int)(playSecond * 100.0 / totalSecond);//+1 } + Console.WriteLine("鎵撳嵃鏃堕棿======"+playTime); + } else { @@ -451,8 +407,8 @@ //鍋滄鎾斁 playView.startTimeBtn.Text =playTime; } - playView.songNameTextView.Text = A31MusicModel.Current.functionMusic.GetAttrState("song_name") == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState("song_name"); - playView.singerBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState("song_name") == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState("song_name"); + playView.songNameTextView.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name) == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name); + playView.singerBtn.Text = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name) == null ? "Unkown" : A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.song_name); //鏇存柊婧愮殑鐣岄潰 // showSourcePage(); } @@ -563,16 +519,45 @@ void PlayListView(FrameLayout frameLayout, VerticalRefreshLayout verticalScrolViewLayout) { verticalScrolViewLayout.RemoveAll(); - var listName = A31MusicModel.Current.functionMusic.GetAttribute("playlist_name").ToString(); + var listName = A31MusicModel.Current.functionMusic.GetAttrState(KeyProperty.playlist_name); var musicList = A31MusicModel.Current.GetSongList(listName); - UI2.FuntionControlView.Music.UpdateThread.PlayMusicClick(verticalScrolViewLayout,"鎾斁鍒楄〃", listName, musicList, frameLayout); + if (musicList.Count == 0) + { + System.Threading.Tasks.Task.Run(() => + { + try + { + A31MusicModel.Current.palyLists.Clear(); + if (A31MusicModel.Current.palyLists.Count == 0) + { + SendMethod.mMethod.GetPalyList(A31MusicModel.Current.functionMusic); + + } + } + catch + { + } + finally + { + Application.RunOnMainThread(() => + { + musicList = A31MusicModel.Current.GetSongList(listName); + A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, frameLayout); + }); + } + }); + } + else + { + A31SongPlay.SongListView(verticalScrolViewLayout, musicList, listName, frameLayout); + } } /// <summary> /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 /// </summary> void UpdateSelectedMusic(FrameLayout frameLayout, VerticalRefreshLayout middViewLayout) { - UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(frameLayout, middViewLayout, A31MusicModel.Current); + UpdateThread.updateCurrMusicThread(frameLayout, middViewLayout, A31MusicModel.Current); } } 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 b912f39..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) - { - Songs musicInfoCN = new Songs(); - 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") - { - Songs musicInfoCN = new Songs(); - 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": - Songs musicInfo = new Songs(); - musicInfo.name = 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 6470d48..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) - { - Songs musicInfoCN = new Songs(); - 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") - { - Songs musicInfoCN = new Songs(); - 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 index ac28bbf..1ec1ba3 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31SongPlay.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31SongPlay.cs @@ -19,7 +19,7 @@ this.BackgroundColor = MusicColor.ViewColor; var topView = new TopView(); this.AddChidren(topView.TopFLayoutView()); - topView.topNameBtn.TextID = StringId.usb; + topView.topNameBtn.TextID = StringId.localMusic; topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); @@ -31,6 +31,10 @@ Height = Application.GetRealHeight(H_W.H - H_W.T_Height), }; this.AddChidren(vv); + vv.BeginHeaderRefreshingAction += () => + { + vv.EndHeaderRefreshing(); + }; ///鍔犺浇闊充箰鍒楄〃 SongListView(vv, musicList, listName); @@ -42,7 +46,7 @@ /// <param name="vv">鐖舵帶浠�</param> /// <param name="musicList">闊充箰鍒楄〃</param> /// <param name="listName">鍒楄〃鍚�</param> - public void SongListView(VerticalRefreshLayout vv,List<Songs> musicList,string listName) { + public static void SongListView(VerticalRefreshLayout vv,List<Songs> musicList,string listName, FrameLayout frame = null) { for (int i = 0; i < musicList.Count; i++) { @@ -65,11 +69,16 @@ //绉婚櫎鐣岄潰 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.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); + SendMethod.mMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); }); }); }; @@ -78,4 +87,63 @@ } } + + 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 8e70d6e..0000000 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31USBMusicList.cs +++ /dev/null @@ -1,89 +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(); - // }); - // } - //}); - - A31MusicModel.Current.USBList.Clear(); - var list = SendMethod.GetUsbList(A31MusicModel.Current); - foreach (var song in list) { - Songs music = new Songs(); - music.name = song.Title; - music.size = song.Size; - music.time = song.Duration; - A31MusicModel.Current.USBList.Add(music); - } - Show(); - middViewLayout.EndHeaderRefreshing(); - }; - #endregion - } - /// <summary> - /// 鍔犺浇鏁版嵁鐨勬柟娉� - /// </summary> - public void Show() - { - middViewLayout.RemoveAll(); - UI2.FuntionControlView.Music.UpdateThread.PlayMusicClick(middViewLayout, "USB", "USBDiskQueue",A31MusicModel.Current.USBList); - } - /// <summary> - /// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰 - /// </summary> - public void UpdateSelectedMusic() - { - UI2.FuntionControlView.Music.UpdateThread.updateCurrMusicThread(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 5ef69f3..e1d37c4 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs @@ -4,20 +4,31 @@ 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鏂规硶 @@ -26,7 +37,8 @@ { base.RemoveFromParent(); clearA31Threads(); - A31MusicModel.ReadMusicStates();//杩涙潵娌℃湁闊充箰琚敹钘忚繃锛岄��鍑烘湁闊充箰琚敹钘忚繃 + //杩涙潵娌℃湁闊充箰琚敹钘忚繃锛岄��鍑烘湁闊充箰琚敹钘忚繃 + //A31MusicModel.ReadMusicStates(); } /// <summary> /// 鍒涘缓绾跨▼鍒楄〃 @@ -83,6 +95,7 @@ { Y = topView.fLayout.Bottom, Height = Application.GetRealHeight(H_W.H - H_W.T_Height), + Name = "verticalRefresh", }; this.AddChidren(verticalRefresh); #endregion @@ -107,7 +120,7 @@ { verticalRefresh.RemoveAll(); - var musicListFunction = SendMethod.sendMethod.GetMusicList; + var musicListFunction = SendMethod.mMethod.GetMusicList; for (int i = 0; i < musicListFunction.Count; i++) { var function = musicListFunction[i]; @@ -122,11 +135,41 @@ } } - for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) { + var a31player = A31MusicModel.A31MusicModelList[i]; - MusicListView(a31player); + if (a31player.functionMusic.online == false) + { + //涓嶅湪绾夸笉鏄剧ず + continue; + } + Application.RunOnMainThread(() => + { + 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 + { + SendMethod.mMethod.RefreshDeviceStatus(new List<string> { a31player.functionMusic.deviceId }); + System.Threading.Thread.Sleep(500); + } + catch { } + + }); } }); @@ -135,17 +178,15 @@ /// <summary> /// 鏄剧ず闊充箰鍒楄〃鐨勬柟娉� /// </summary> - void MusicListView(A31MusicModel player) + void MusicListView(A31MusicModel player) { - musicView.View(verticalRefresh); - musicView.singerBtn.Text = player.functionMusic.GetAttrState("song_name"); - musicView.songNameBtn.Text = player.functionMusic.GetAttrState("song_name"); + 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; - //if (player.IsEnd) - //{ - // musicView.muiscFl.Height = Application.GetRealHeight(12 + 139 + 12); - //} + ///鏀惰棌浜嬩欢 musicView.collectIconBtn.MouseUpEventHandler += (sender, e) => { musicView.collectIconBtn.IsSelected = !musicView.collectIconBtn.IsSelected; @@ -159,21 +200,8 @@ } }; - EventHandler<MouseEventArgs> clickMergence = (sender, e) => - { - //if (player.ServerClientType == 0) - //{ - // new View.DialogView { }.PlayMergence(player); - //} - //else if (player.ServerClientType == 1) - //{ - // new View.DialogView { }.DetachPlayMergence(player); - //} - }; - musicView.mergeBjBtn.MouseUpEventHandler += clickMergence; - musicView.mergeBtn.MouseUpEventHandler += clickMergence; - musicView.mergeIconBtn.MouseUpEventHandler += clickMergence; + ///杩涘叆闊充箰涓婚〉浜嬩欢 EventHandler<MouseEventArgs> clickPlayView = (sender, e) => { @@ -194,10 +222,10 @@ musicView.prevBtn.MouseDownEventHandler += (sender, e) => { musicView.prevBtn.IsSelected = true; - player.functionMusic.SetAttrState("song_step", "up"); + player.functionMusic.SetAttrState(KeyProperty.song_step, ValueProperty.up); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("song_step", "up"); - SendMethod.sendMethod.SendControlCommand(player.functionMusic, dic); + dic.Add(KeyProperty.song_step, ValueProperty.up); + SendMethod.mMethod.SendControlCommand(player.functionMusic, dic); }; musicView.prevBtn.MouseUpEventHandler += (sender, e) => { @@ -206,55 +234,54 @@ ///鏆傚仠/鎾斁鐐瑰嚮浜嬩欢 musicView.playBtn.MouseDownEventHandler += (sender, e) => { - string status = "off"; + string status = ValueProperty.off; if (musicView.playBtn.IsSelected) { musicView.playBtn.IsSelected = false; - status = "off"; + status = ValueProperty.off; } else { musicView.playBtn.IsSelected = true; - status = "on"; + status = ValueProperty.on; } - player.functionMusic.SetAttrState("on_off", status); + player.functionMusic.SetAttrState(KeyProperty.on_off, status); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("on_off", status); - SendMethod.sendMethod.SendControlCommand(player.functionMusic, dic); + dic.Add(KeyProperty.on_off, status); + SendMethod.mMethod.SendControlCommand(player.functionMusic, dic); }; ///涓嬩竴鏇茬偣鍑讳簨浠� musicView.nextBtn.MouseDownEventHandler += (sender, e) => { musicView.nextBtn.IsSelected = true; - player.functionMusic.SetAttrState("song_step", "down"); + player.functionMusic.SetAttrState(KeyProperty.song_step, ValueProperty.down); Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("song_step", "down"); - SendMethod.sendMethod.SendControlCommand(player.functionMusic, dic); + 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 (!player.functionMusic.online) { ///涓嶅湪绾夸笉璇荤姸鎬� continue; } //SendMethod.ReadStatus(player); - SendMethod.sendMethod.RefreshDeviceStatus(player.functionMusic,new List<string> { player.functionMusic.deviceId }); - + SendMethod.mMethod.GetDeviceStatus(ref player, new List<string> { player.functionMusic.deviceId }, player.functionMusic.sid); + System.Threading.Thread.Sleep(1000); Application.RunOnMainThread(() => { - musicView.singerBtn.Text = player.functionMusic.GetAttrState("song_name"); - musicView.songNameBtn.Text = player.functionMusic.GetAttrState("song_name"); + 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.A31PlayStatus.status == "play") + if (player.functionMusic.GetAttrState(KeyProperty.on_off) == ValueProperty.on) { musicView.playBtn.IsSelected = true; } @@ -263,27 +290,14 @@ musicView.playBtn.IsSelected = false; } musicView.regionBtn.Text = player.functionMusic.GetRoomListName(); - if (player.ServerClientType == 1) + + if (player.functionMusic.collect) { - if (player.MainPlayCollection) - { - musicView.collectIconBtn.IsSelected = true; - } - else - { - musicView.collectIconBtn.IsSelected = false; - } + musicView.collectIconBtn.IsSelected = true; } else { - if (player.functionMusic.collect) - { - musicView.collectIconBtn.IsSelected = true; - } - else - { - musicView.collectIconBtn.IsSelected = false; - } + musicView.collectIconBtn.IsSelected = false; } }); } @@ -297,58 +311,112 @@ ///鎸囧畾鍒锋柊鐣岄潰 /// </summary> /// <param name="strView">鍒ゆ柇瀛楃</param> - public void RefreshView(string strView) + public void RefreshView(AlinkStatusData alinkStatusData) { + if (alinkStatusData == null || alinkStatusData.status.Count == 0) + { + return; + } Application.RunOnMainThread(() => { try { - - for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) + for (int a =0; a < MainPage.BasePageView.ChildrenCount; a++) { - var view = MainPage.BasePageView.GetChildren(i); - if (strView == view.Tag.ToString()) + var view = MainPage.BasePageView.GetChildren(a); + if (view.GetType() == typeof(MusicMain)) { - if (view.GetType() == typeof(MusicMain)) + var musicMain = view as MusicMain; + if (musicMain != null) { - //musicView.singerBtn.Text = player.A31PlayStatus.Artist; - //musicView.songNameBtn.Text = player.A31PlayStatus.Title; - //musicView.musicNameBtn.Text = new View.DialogView { }.NamePlayer(player); - //if (player.A31PlayStatus.status == "play") - //{ - // musicView.playBtn.IsSelected = true; - //} - //else - //{ - // musicView.playBtn.IsSelected = false; - //} - //musicView.regionBtn.Text = player.GetRoomListName(); - //if (player.ServerClientType == 1) - //{ - // if (player.MainPlayCollection) - // { - // musicView.collectIconBtn.IsSelected = true; - // } - // else - // { - // musicView.collectIconBtn.IsSelected = false; - // } - //} - //else - //{ - // if (player.collect) - // { - // musicView.collectIconBtn.IsSelected = true; - // } - // else - // { - // musicView.collectIconBtn.IsSelected = false; - // } - //} - } - } + for (int b = 0; b < musicMain.ChildrenCount; b++) + { + var view1 = musicMain.GetChildren(b); + if (view1.GetType() == typeof(VerticalRefreshLayout)) + { + 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; + } + + } + } + } + } + + } + } + } + + } + } + + } + + } + } + + } } + } 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 56992b1..65c783a 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs @@ -12,895 +12,19 @@ { public class SendMethod { - private static SendMethod m_sendMethod=null; - public static SendMethod sendMethod + private static SendMethod sMethod=null; + public static SendMethod mMethod { get { - if (m_sendMethod == null) + if (sMethod == null) { - m_sendMethod = new SendMethod(); + sMethod = new SendMethod(); } - return m_sendMethod; + return sMethod; } } - - /// <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") - { - System.Threading.Tasks.Task.Run(() => - { - System.Net.Sockets.UdpClient udpClient = null; - int localPort = 65535; - for (; 1024 < localPort; localPort--) - { - try - { - udpClient = new System.Net.Sockets.UdpClient(localPort); - break; - } - catch (Exception e) { System.Console.WriteLine(e.Message); } - } - - 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) - { - 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)) - { - 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;"); - - } - 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.functionMusic); - foreach (var e in A31MusicModel.A31MusicModelList) - { - RoomPage.UpdataStates(e.functionMusic); - } - }); - #endregion - } - } - - 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) - { - 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) - { - //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>", ""); - } - } - 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<Songs> GetUsbList(A31MusicModel a31player) - { - var musicInfoList = new List<Songs>(); - 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) - { - Songs musicInfo = new Songs(); - 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> - /// <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) - { - - //鏈�澶у彂閫佺殑鏉℃暟 - 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); - } - catch - { - - } - } - - - - static System.Threading.Thread thread; - /// <summary> - /// 淇敼钃濈墮鍚嶇О - /// </summary> - /// <param name="message"></param> - public static void ModifyBluetoothName(string message) - { - 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; - - 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; - } - /// <summary> /// 鑾峰彇闊充箰鍒楄〃 /// </summary> @@ -926,10 +50,33 @@ } /// <summary> + /// 鑾峰彇璁惧鏈�鏂扮殑鐘舵�� + /// </summary> + /// <returns></returns> + public void GetDeviceStatus(ref A31MusicModel a31Music, List<string> functionIds, string sid) + { + try + { + //RefreshDeviceStatus(functionIds); + a31Music.LastDateTime = DateTime.Now; + ///浠庣紦瀛橀噷闈㈡煡鎵鹃煶涔愭挱鏀惧櫒瀵硅薄<缂撳瓨鏁版嵁鏀跺埌鎺ㄩ�佽繃鏉ョ殑鐘舵�佷細鏇存柊缂撳瓨鏁版嵁> + var allLocalFuntion = FunctionList.List.GetDeviceFunctionList(); + var localFunction = allLocalFuntion.Find((obj) => obj.sid == sid); + if (localFunction == null) + { + return; + } + ///鏇存柊鐨勬暟鎹� + a31Music.functionMusic = localFunction; + } + catch { } + } + + /// <summary> /// 鍒锋柊璁惧鐘舵�� /// </summary> /// <returns></returns> - public void RefreshDeviceStatus(Function music, List<string> functionIds) + public void RefreshDeviceStatus(List<string> functionIds) { try { @@ -937,27 +84,29 @@ 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() != "") + if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") { return; } - //鏁版嵁杩斿簭鍒楀寲涓篎unction瀵硅薄 - var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data); - var function = Newtonsoft.Json.JsonConvert.DeserializeObject<Function>(str); - if (function == null) - { - return; - } - music.name = function.name; - music.sid = function.sid; - music.spk = function.spk; - music.status = function.status; - music.roomIds = function.roomIds; - music.attributes = function.attributes; } 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> 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 0f2196d..0000000 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/UpdateThread.cs +++ /dev/null @@ -1,200 +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 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(); - } - /// <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 PlayMusicClick(VerticalRefreshLayout middViewLayout, string musicSource, string listName,List<Songs> musicList, 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.name == songs.name); - if (music1 == null) - { - ///娌℃湁瀛樺湪灏辨坊鍔� - A31MusicModel.Current.LoveMusicInfoList.Add(songs); - } - } - else - { - ///鏌ユ壘闊充箰鏄惁瀛樺湪鍦ㄥ垪琛� - var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.name == songs.name); - 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(() => - { - //绉婚櫎鐣岄潰 - if (frame != null) - { - frame.RemoveFromParent(); - } - MainPage.BasePageView.RemoveViewByTag("Music"); - - A31MusicModel.Current.functionMusic.SetAttrState("song_name", songView.songBtn.Text); - A31MusicModel.Current.functionMusic.SetAttrState("playlist_name", listName); - Dictionary<string, string> dic = new Dictionary<string, string>(); - dic.Add("song_name", songView.songBtn.Text); - dic.Add("playlist_name", listName); - System.Threading.Tasks.Task.Run(() => - { - SendMethod.sendMethod.SendControlCommand(A31MusicModel.Current.functionMusic, dic); - }); - }); - }); - }; - - } - } - } -} diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/View/DialogView.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/View/DialogView.cs index f8cc250..0da47b3 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/View/DialogView.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/View/DialogView.cs @@ -223,1241 +223,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.functionMusic.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(); - } } [System.Serializable] 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/PlayView.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/View/PlayView.cs index b054490..86aca36 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/View/PlayView.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/View/PlayView.cs @@ -86,11 +86,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 +209,7 @@ SeekBarViewHeight = Application.GetRealWidth(8),//杩涘害鏉$殑楂樺害 ProgressChangeDelayTime = 300,//0.3绉掑彂閫佷竴娆� SeekBarPadding = Application.GetRealWidth(20), + }; /// <summary> @@ -264,6 +267,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