From 6657fd3d6975e3a8e5ad9fe1b4b6b23d7e388522 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 26 五月 2020 17:49:25 +0800
Subject: [PATCH] 2020-05-26-3
---
HDL_ON/UI/Music/A31MyList.cs | 221 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
HDL_ON/UI/Music/A31MyListMusic.cs | 2
HDL-ON_Android/Assets/Phone/.DS_Store | 0
HDL_ON/UI/Music/A31MusicSourcePage.cs | 1
.vs/HDL_APP_Project/xs/sqlite3/storage.ide | 0
.vs/HDL_APP_Project/xs/UserPrefs.xml | 13 ++-
.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal | 0
7 files changed, 230 insertions(+), 7 deletions(-)
diff --git a/.vs/HDL_APP_Project/xs/UserPrefs.xml b/.vs/HDL_APP_Project/xs/UserPrefs.xml
index 3580ae7..fd47087 100644
--- a/.vs/HDL_APP_Project/xs/UserPrefs.xml
+++ b/.vs/HDL_APP_Project/xs/UserPrefs.xml
@@ -1,7 +1,13 @@
锘�<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default">
- <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/Music/A31PlayMusicPage.cs">
+ <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/Music/A31MusicSourcePage.cs">
<Files>
- <File FileName="HDL_ON/UI/Music/A31PlayMusicPage.cs" Line="32" Column="1" />
+ <File FileName="HDL_ON/UI/Music/A31PlayMusicPage.cs" Line="525" Column="23" />
+ <File FileName="../鏃х増鏈琈usic/MyMusic.cs" Line="813" Column="70" />
+ <File FileName="HDL_ON/UI/Music/A31MusicModel.cs" Line="64" Column="1" />
+ <File FileName="HDL_ON/UI/Music/A31USBMusicList.cs" Line="19" Column="33" />
+ <File FileName="HDL_ON/UI/Music/A31MyList.cs" Line="7" Column="27" />
+ <File FileName="HDL_ON/UI/Music/A31MyListMusic.cs" Line="29" Column="46" />
+ <File FileName="HDL_ON/UI/Music/A31MusicSourcePage.cs" Line="201" Column="36" />
</Files>
<Pads>
<Pad Id="ProjectPad">
@@ -11,8 +17,7 @@
<Node name="Common" expanded="True" />
<Node name="UI" expanded="True">
<Node name="Music" expanded="True">
- <Node name="View" expanded="True" />
- <Node name="A31PlayMusicPage.cs" selected="True" />
+ <Node name="A31MusicSourcePage.cs" selected="True" />
</Node>
</Node>
</Node>
diff --git a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide
index adda9c2..6325d97 100644
--- a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide
+++ b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide
Binary files differ
diff --git a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal
index 6977e38..1d6b710 100644
--- a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal
+++ b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal
Binary files differ
diff --git a/HDL-ON_Android/Assets/Phone/.DS_Store b/HDL-ON_Android/Assets/Phone/.DS_Store
index 726e9b4..f17f671 100644
--- a/HDL-ON_Android/Assets/Phone/.DS_Store
+++ b/HDL-ON_Android/Assets/Phone/.DS_Store
Binary files differ
diff --git a/HDL_ON/UI/Music/A31MusicSourcePage.cs b/HDL_ON/UI/Music/A31MusicSourcePage.cs
index 5320fea..ee04479 100644
--- a/HDL_ON/UI/Music/A31MusicSourcePage.cs
+++ b/HDL_ON/UI/Music/A31MusicSourcePage.cs
@@ -201,6 +201,7 @@
A31MyList a31MyList = new A31MyList();
MainPage.BasePageView.AddChidren(a31MyList);
a31MyList.Show();
+ a31MyList.UpdateSelectedMusic();
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
};
///鏈湴闊充箰浜嬩欢
diff --git a/HDL_ON/UI/Music/A31MyList.cs b/HDL_ON/UI/Music/A31MyList.cs
index ef38e27..a58e1f3 100644
--- a/HDL_ON/UI/Music/A31MyList.cs
+++ b/HDL_ON/UI/Music/A31MyList.cs
@@ -1,5 +1,6 @@
锘縰sing System;
using System.Collections.Generic;
+using System.Text;
using Shared;
namespace HDL_ON.UI.Music
{
@@ -18,6 +19,11 @@
topView.topNameBtn.TextID = StringId.myList;
topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
{
+
+ if (updateSelectedMusicThread == null || updateSelectedMusicThread.IsAlive)
+ {
+ updateSelectedMusicThread.Abort();
+ }
this.RemoveFromParent();
};
@@ -96,12 +102,33 @@
Height = Application.GetMinRealAverage(24),
UnSelectedImagePath = "MusicIcon/filePause.png",
SelectedImagePath = "MusicIcon/filePlay.png",
+ Tag= list.ListName,
};
addFlieRow.AddChidren(playIconBtn);
playIconBtn.MouseUpEventHandler += (sender, e) =>
{
+ if (list.MusicInfoList.Count == 0)
+ {
+ return;
+ }
+ ///鍙栭殢鏈烘暟;
+ 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(() =>
+ {
+ PushList(songs, list.ListName, list.MusicInfoList);
+ });
+ });
+ });
};
//鏂囦欢鍚嶆帶浠�
Button fileNameBtn = new Button
@@ -165,8 +192,7 @@
});
};
-
-
+
Button clickBtn = new Button
{
X = fileIconBtn.Right + Application.GetRealWidth(16),
@@ -185,6 +211,197 @@
}
}
+ /// <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++)
+ {
+ RowLayout view = (RowLayout)middViewLayout.GetChildren(i);
+ var playBtn = (Button)view.GetChildren(1);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button
+ if (A31MusicModel.Current.A31PlayStatus.Artist == playBtn.Tag.ToString())
+ {
+ playBtn.IsSelected = true;
+ }
+ else
+ {
+ playBtn.IsSelected = false;
+ }
+ }
+ }
+ catch { }
+ });
+ }
+ });
+ 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/Music/A31MyListMusic.cs b/HDL_ON/UI/Music/A31MyListMusic.cs
index 302f73e..754a81c 100644
--- a/HDL_ON/UI/Music/A31MyListMusic.cs
+++ b/HDL_ON/UI/Music/A31MyListMusic.cs
@@ -363,7 +363,7 @@
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;" + tempMusicInfo.Artist + "&lt;/upnp:artist&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;");
--
Gitblit v1.8.0