From 84e76cf2fcbe26142750131d3c27eaac0335e40a Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 11 三月 2021 11:04:08 +0800
Subject: [PATCH] 上传一个添加红外宝 Ios 版本
---
HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveMusicList.cs | 367 +---------------------------------------------------
1 files changed, 7 insertions(+), 360 deletions(-)
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveMusicList.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveMusicList.cs
index af52c41..e0a95e1 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveMusicList.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31LoveMusicList.cs
@@ -21,30 +21,17 @@
{
#region 鐣岄潰甯冨眬------
- this.BackgroundColor = Color.ViewColor;
+ this.BackgroundColor = MusicColor.ViewColor;
var topView = new TopView();
this.AddChidren(topView.TopFLayoutView());
- topView.topNameBtn.TextID = StringId.a31Music;
+ topView.topNameBtn.TextID = StringId.myLove;//a31Music;
topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
{
-
- if (updateSelectedMusicThread != null)
- {
- try
- {
- if (updateSelectedMusicThread.IsAlive)
- {
- updateSelectedMusicThread.Abort();
- ///鍏抽棴绾跨▼
- }
- }
- catch { }
- }
this.RemoveFromParent();
};
middViewLayout = new VerticalRefreshLayout
{
- BackgroundColor = Color.WhiteColor,
+ BackgroundColor = MusicColor.WhiteColor,
Y = topView.fLayout.Bottom,
Height = Application.GetRealHeight(H_W.H - H_W.T_Height),
};
@@ -54,7 +41,7 @@
middViewLayout.EndHeaderRefreshing();
};
#endregion
- MusicView(Language.StringByID(StringId.a31Music));
+ MusicView(Language.StringByID(StringId.myLove));
}
/// <summary>
/// 鍔犺浇鏁版嵁鐨勬柟娉�
@@ -62,356 +49,16 @@
public void MusicView(string listName)
{
middViewLayout.RemoveAll();
- for (int i = 0; i < A31MusicModel.Current.LoveMusicInfoList.Count; i++)
- {
- var songs = A31MusicModel.Current.LoveMusicInfoList[i];
- if (string.IsNullOrEmpty(songs.Title))
- {
- //闃叉姝屾洸鍚嶅瓧涓虹┖鎶涘紓甯�
- songs.Title = " ";
- }
- if (string.IsNullOrEmpty(songs.Artist))
- {
- //闃叉姝屾墜鍚嶅瓧涓虹┖鎶涘紓甯�
- songs.Artist = " ";
- }
- FrameLayout musicViewFl = new FrameLayout
- {
- Width = Application.GetRealWidth(375),
- Height = Application.GetRealHeight(44),
- };
- middViewLayout.AddChidren(musicViewFl);
- //鍒楄〃褰撳墠鎾斁闊充箰鍥炬爣
- Button playIconBtn = new Button
- {
- X = Application.GetRealWidth(16),
- Y = Application.GetRealHeight(10),
- Width = Application.GetMinRealAverage(24),
- Height = Application.GetMinRealAverage(24),
- UnSelectedImagePath = "MusicIcon/playStatus.png",
- Visible = false,
- Name = "playStatus",
- Tag = songs.URL,
- };
- musicViewFl.AddChidren(playIconBtn);
- //姝屾洸鎺т欢
- Button songBtn = new Button
- {
- X = Application.GetRealWidth(16),
- Y = Application.GetRealHeight(11),
- Width = Application.GetRealWidth(100),
- Height = Application.GetRealHeight(22),
- TextColor = Color.MusicTxet14Color,
- TextSize = TextSize.Text16,
- TextAlignment = TextAlignment.CenterLeft,
- Name = "song",
- Tag = songs.URL,
- Text = songs.Title.Trim()
- };
- musicViewFl.AddChidren(songBtn);
- var wText = songBtn.GetTextWidth();//鑾峰彇鏂囨湰瀹藉害
- ///(姝屾洸+姝屾墜)瀹藉害鏈�澶у�兼椂280
- if (wText > 280)
- {
-
- songBtn.Width = Application.GetRealWidth(280);
- }
- else
- {
- songBtn.Width = wText + 5;
- }
- //姝屾墜鎺т欢
- Button singerBtn = new Button
- {
- X = songBtn.Right,
- Y = Application.GetRealHeight(11),
- Width = Application.GetRealWidth(280 - songBtn.Width),
- Height = Application.GetRealHeight(22),
- TextColor = Color.MusicNoTxetColor,
- TextSize = TextSize.Text12,
- TextAlignment = TextAlignment.CenterLeft,
- //Text =("-" +songs.Artist).Trim(),
- Name = "singer",
- Tag = songs.URL,
- Text = "-" + songs.Artist.Trim()
- };
- musicViewFl.AddChidren(singerBtn);
- if (wText > 280)
- {
- ///姝屽悕闀垮害灏忎簬250鎵嶅彲浠ユ樉绀烘瓕鎵嬪嚭鏉�
- singerBtn.Width = Application.GetRealWidth(0);
- }
- //娣诲姞鍠滅埍闊充箰鎺т欢
- Button loveIcon = new Button
- {
- X = Application.GetRealWidth(291),
- Y = Application.GetRealHeight(8),
- Width = Application.GetMinRealAverage(28),
- Height = Application.GetMinRealAverage(28),
- UnSelectedImagePath = "MusicIcon/loveSelected.png",
- };
- musicViewFl.AddChidren(loveIcon);
- loveIcon.MouseUpEventHandler += (sender, e) =>
- {
- var music= A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
- if (music!= null)
- {
- ///瀛樺湪灏卞垹闄�
- A31MusicModel.Current.LoveMusicInfoList.Remove(music);
- }
- A31MusicModel.Save();
- musicViewFl.RemoveFromParent();
- };
-
- //娣诲姞鍒版垜鐨勫垪琛�
- Button addIcon = new Button
- {
- X = Application.GetRealWidth(335),
- Y = Application.GetRealHeight(8),
- Width = Application.GetMinRealAverage(28),
- Height = Application.GetMinRealAverage(28),
- UnSelectedImagePath = "MusicIcon/addMusic1.png",
- };
- musicViewFl.AddChidren(addIcon);
- addIcon.MouseUpEventHandler = (sender, e) =>
- {
- new View.DialogView { }.FieListView(songs);
- };
-
- //鐐瑰嚮鎺т欢
- Button clickBtn = new Button
- {
- Width = Application.GetRealWidth(280),
- Height = Application.GetRealHeight(44),
- Tag = songs,//鏍囪鎾斁鍝竴棣栨瓕鏇�
- };
- musicViewFl.AddChidren(clickBtn);
- ///鐐瑰嚮鎾斁浜嬩欢
- clickBtn.MouseUpEventHandler += (sender, e) =>
- {
-
- System.Threading.Tasks.Task.Run(() =>
- {
- System.Threading.Thread.Sleep(50);
- Application.RunOnMainThread(() =>
- {
- //绉婚櫎鐣岄潰
- A31MusicModel.Current.A31PlayStatus.Title = songBtn.Text;
- MainPage.BasePageView.RemoveViewByTag("Music");
- System.Threading.Tasks.Task.Run(() =>
- {
- PushList(songs, listName, A31MusicModel.Current.LoveMusicInfoList);
- });
- });
- });
-
- };
-
- }
+ UI2.FuntionControlView.Music.UpdateThread.playMusuc(middViewLayout, "鎴戠殑鏈�鐖�", listName, A31MusicModel.Current.LoveMusicInfoList, A31MusicModel.Current);
}
/// <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 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.Current.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString())
- {
- volIconBtn.Visible = true;
- songNameBtn.TextColor = Color.SelectedColor;
- songNameBtn.X = Application.GetRealWidth(48);
- artistNameBtn.X = songNameBtn.Right;
- artistNameBtn.TextColor = Color.SelectedColor;
- }
- else
- {
- volIconBtn.Visible = false;
- songNameBtn.TextColor = Color.MusicTxet14Color;
- songNameBtn.X = Application.GetRealWidth(16);
- artistNameBtn.X = songNameBtn.Right;
- artistNameBtn.TextColor = Color.MusicNoTxetColor;
- }
-
-
- }
- }
- catch { }
-
- });
- }
- });
- updateSelectedMusicThread.Start();
+ UI2.FuntionControlView.Music.UpdateThread.updateThread(this, middViewLayout,A31MusicModel.Current);
}
- /// <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 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
- {
-
- }
- }
+
}
}
--
Gitblit v1.8.0