using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using Shared;
|
using Shared.SimpleControl;
|
using Shared.SimpleControl.R;
|
using Shared.SimpleControl.Phone;
|
using System.Xml;
|
using Shared.Net;
|
using SmartHome.UI.SimpleControl.Phone.Music;
|
|
namespace Shared.SimpleControl.Phone.Music
|
{
|
/// <summary>
|
/// 本地音乐
|
/// </summary>
|
class A31LocalMusic : FrameLayout
|
{
|
/// <summary>
|
/// 歌曲
|
/// </summary>
|
Button songs;
|
/// <summary>
|
/// 歌手
|
/// </summary>
|
Button artists;
|
/// <summary>
|
/// 专辑
|
/// </summary>
|
Button albums;
|
|
bool isExited;
|
public void Show (A31MusicModel a31)
|
{
|
|
AddChidren (new Button {
|
Height = Application.GetRealHeight (36),
|
BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
|
});
|
|
var topFrameLayout = new FrameLayout {
|
Height = Application.GetRealHeight (100),
|
Y = Application.GetRealHeight (36),
|
BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
|
};
|
AddChidren (topFrameLayout);
|
|
var LocallistName = new Button {
|
TextID = MyInternationalizationString.LocalMusic,
|
TextColor=SkinStyle.Current.MusicTextColor,
|
};
|
topFrameLayout.AddChidren (LocallistName);
|
|
var hdl = new Button {
|
Width = Application.GetRealWidth (154),
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (486),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = MainPage.LogoString,
|
};
|
topFrameLayout.AddChidren (hdl);
|
|
var back = new Button {
|
Width = Application.GetRealWidth (82),
|
Height = Application.GetRealHeight (89),
|
X = Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/HomepageBack.png",
|
};
|
topFrameLayout.AddChidren (back);
|
back.MouseDownEventHandler += (sender, e) => {
|
RemoveFromParent ();
|
isExited = true;
|
};
|
|
var middle = new VerticalScrolViewLayout ();
|
middle.Y = topFrameLayout.Bottom;
|
middle.Height = Application.GetRealHeight (Application.DesignHeight - 136 - 110);
|
middle.BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout;
|
AddChidren (middle);
|
|
#region 本地音乐
|
List<Button> buttonList = new List<Button> (100);
|
foreach (var musicInfo in MusicInfo.MusicInfoList)
|
{
|
if(musicInfo == null)
|
{
|
continue;
|
}
|
|
musicInfo.URL = "http://" + new NetWiFi ().IpAddress + ":" + com.hdl.on.Server.Port + "/" + musicInfo.ID;
|
|
var rowLa = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
|
};
|
middle.AddChidren (rowLa);
|
|
var title = new Button {
|
Width = Application.GetRealWidth (61),
|
Height = Application.GetRealHeight (61),
|
X = Application.GetRealWidth (20),
|
Gravity = Gravity.CenterVertical,
|
Radius = (uint)Application.GetRealHeight (4),
|
UnSelectedImagePath = "MusicIcon/musicplay1.png",
|
};
|
rowLa.AddChidren (title);
|
|
var path = "";
|
if (Shared.Application.IsPad) {
|
path = "Pad/" + "MusicImage/AlbumArtistImage_";
|
} else {
|
path = "Phone/" + "MusicImage/AlbumArtistImage_";
|
}
|
if (Shared.IO.FileUtils.Exists (path + musicInfo.Album)) {
|
title.UnSelectedImagePath = path + musicInfo.Album;
|
} else if (Shared.IO.FileUtils.Exists (path + musicInfo.Artist)) {
|
title.UnSelectedImagePath = path + musicInfo.Artist;
|
} else {
|
title.UnSelectedImagePath = "MusicIcon/musicplay1.png";
|
title.AddTag ("Album", musicInfo.Album);
|
title.AddTag ("Artist", musicInfo.Artist);
|
buttonList.Add (title);
|
}
|
|
var addlikelits = new Button {
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (58),
|
X = Application.GetRealWidth (560),
|
UnSelectedImagePath = "MusicIcon/add.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
rowLa.AddChidren (addlikelits);
|
|
addlikelits.MouseUpEventHandler += (sender1, e1) => {
|
A31MyList A31MyList = new A31MyList ();
|
MainPage.MainFrameLayout.AddChidren (A31MyList);
|
A31MyList.Show (musicInfo);
|
};
|
|
var listmusic = new Button {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetRealHeight (50),
|
Text = musicInfo.Title,
|
TextAlignment = TextAlignment.BottomLeft,
|
X = Application.GetRealWidth (100),
|
Tag = musicInfo,
|
TextColor = SkinStyle.Current.MusicTextColor,
|
|
};
|
rowLa.AddChidren (listmusic);
|
|
var artists = new Button {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetRealHeight (50),
|
TextAlignment = TextAlignment.TopLeft,
|
X = Application.GetRealWidth (100),
|
Y = listmusic.Bottom,
|
//TextColor = 0x75ffffff,
|
Text = musicInfo.Artist + "-" + musicInfo.Album,
|
Tag = musicInfo,
|
TextColor = SkinStyle.Current.MusicArtistTextColor,
|
};
|
rowLa.AddChidren (artists);
|
|
EventHandler<MouseEventArgs> musics = (sender, e) => {
|
rowLa.BackgroundColor = 0xffFE5E00;
|
System.Threading.Tasks.Task.Run (() => {
|
System.Threading.Thread.Sleep (50);
|
Application.RunOnMainThread (() => {
|
//先移除当前控件的前面那个控件界面
|
//this.Parent.RemoveAt (this.Parent.ChildrenCount - 3);
|
this.Parent.RemoveAt (this.Parent.ChildrenCount - 2);
|
//当前控件界面
|
this.RemoveFromParent ();
|
MainPage.MainFrameLayout.RemoveViewByTag ("A31PlayMusicPage");
|
A31PlayMusicPage a31PlayMusic = new A31PlayMusicPage ();
|
MainPage.MainFrameLayout.AddChidren (a31PlayMusic);
|
a31PlayMusic.Show (MusicInfo.MusicInfoList);
|
//a31PlayMusic.Source = "SONGLIST-NETWORK";
|
a31.A31PlayStatus.Title = listmusic.Text;
|
System.Threading.Tasks.Task.Run (() => {
|
pushList (a31, listmusic.Tag as MusicInfo, Language.StringByID (MyInternationalizationString.LocalMusic));
|
});
|
});
|
});
|
};
|
listmusic.MouseUpEventHandler += musics;
|
artists.MouseUpEventHandler += musics;
|
}
|
#endregion
|
|
|
var frameLayout = new FrameLayout {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (110),
|
//BackgroundImagePath = "MusicIcon/ListbottomBackground.png",
|
BackgroundColor=SkinStyle.Current.MusicMiddleBackgroundColor,
|
Y = middle.Bottom,
|
};
|
AddChidren (frameLayout);
|
|
//歌曲
|
songs = new Button {
|
Width = Application.GetRealWidth (640 / 3),
|
Height = Application.GetRealHeight (100),
|
TextID = MyInternationalizationString.Musicsong,
|
TextSize = 18,
|
Tag = a31,
|
//IsSelected = true,
|
TextColor = 0xffFE5E00,
|
};
|
frameLayout.AddChidren (songs);
|
songs.MouseDownEventHandler += (sender, e) => {
|
songs.TextColor = 0xffFE5E00;
|
artists.TextColor = SkinStyle.Current.MusicTextColor;
|
albums.TextColor = SkinStyle.Current.MusicTextColor;
|
|
middle.RemoveAll ();
|
for (int i = 0; i < MusicInfo.MusicInfoList.Count; i++) {
|
var musicInfo = MusicInfo.MusicInfoList [i];
|
musicInfo.URL = "http://" + new NetWiFi ().IpAddress + ":" + com.hdl.on.Server.Port + "/" + musicInfo.ID;
|
var rowLa = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
|
};
|
middle.AddChidren (rowLa);
|
|
var title = new Button {
|
Width = Application.GetRealWidth (61),
|
Height = Application.GetRealHeight (61),
|
X = Application.GetRealWidth (20),
|
Gravity = Gravity.CenterVertical,
|
Radius = (uint)Application.GetRealHeight (4),
|
UnSelectedImagePath = "MusicIcon/musicplay1.png",
|
};
|
rowLa.AddChidren (title);
|
|
var path = "";
|
if (Shared.Application.IsPad) {
|
path = "Pad/" + "MusicImage/AlbumArtistImage_";
|
} else {
|
path = "Phone/" + "MusicImage/AlbumArtistImage_";
|
}
|
if (Shared.IO.FileUtils.Exists (path + musicInfo.Album)) {
|
title.UnSelectedImagePath = path + musicInfo.Album;
|
} else if (Shared.IO.FileUtils.Exists (path + musicInfo.Artist)) {
|
title.UnSelectedImagePath = path + musicInfo.Artist;
|
} else {
|
title.UnSelectedImagePath = "MusicIcon/musicplay1.png";
|
title.AddTag ("Album", musicInfo.Album);
|
title.AddTag ("Artist", musicInfo.Artist);
|
buttonList.Add (title);
|
}
|
|
var addlikelits = new Button {
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (58),
|
X = Application.GetRealWidth (560),
|
UnSelectedImagePath = "MusicIcon/add.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
rowLa.AddChidren (addlikelits);
|
addlikelits.MouseUpEventHandler += (sender1, e1) => {
|
A31MyList A31MyList = new A31MyList ();
|
MainPage.MainFrameLayout.AddChidren (A31MyList);
|
A31MyList.Show (musicInfo);
|
};
|
|
var listmusic = new Button {
|
Width = Application.GetRealWidth (450),
|
Height = Application.GetRealHeight (60),
|
Text = musicInfo.Title,
|
TextAlignment = TextAlignment.BottomLeft,
|
X = Application.GetRealWidth (100),
|
Tag = musicInfo,
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
rowLa.AddChidren (listmusic);
|
|
var artists = new Button {
|
Width = Application.GetRealWidth (450),
|
Height = Application.GetRealHeight (40),
|
TextAlignment = TextAlignment.TopLeft,
|
X = Application.GetRealWidth (100),
|
Y = listmusic.Bottom,
|
//TextColor = 0x75ffffff,
|
Text = musicInfo.Artist + "-" + musicInfo.Album,
|
Tag = musicInfo,
|
TextColor = SkinStyle.Current.MusicArtistTextColor,
|
};
|
rowLa.AddChidren (artists);
|
|
EventHandler<MouseEventArgs> musics = (sender1, e1) => {
|
rowLa.BackgroundColor = 0xffFE5E00;
|
System.Threading.Tasks.Task.Run (() => {
|
System.Threading.Thread.Sleep (50);
|
Application.RunOnMainThread (() => {
|
//先移除当前控件的前面那个控件界面
|
this.Parent.RemoveAt (this.Parent.ChildrenCount - 3);
|
this.Parent.RemoveAt (this.Parent.ChildrenCount - 2);
|
//当前控件界面
|
this.RemoveFromParent ();
|
A31PlayMusicPage a31PlayMusic = new A31PlayMusicPage ();
|
MainPage.MainFrameLayout.AddChidren (a31PlayMusic);
|
a31PlayMusic.Show (MusicInfo.MusicInfoList);
|
//a31PlayMusic.Source = "SONGLIST-NETWORK";
|
a31.A31PlayStatus.Title = listmusic.Text;
|
System.Threading.Tasks.Task.Run (() => {
|
pushList (a31, listmusic.Tag as MusicInfo, Language.StringByID (MyInternationalizationString.LocalMusic));
|
});
|
});
|
});
|
};
|
listmusic.MouseUpEventHandler += musics;
|
artists.MouseUpEventHandler += musics;
|
|
}
|
};
|
|
//歌手名
|
artists = new Button {
|
Width = Application.GetRealWidth (640 / 3),
|
Height = Application.GetRealHeight (100),
|
X = songs.Right,
|
TextID = MyInternationalizationString.Musicartist,
|
TextSize = 18,
|
Tag = a31,
|
TextColor=SkinStyle.Current.MusicTextColor,
|
};
|
frameLayout.AddChidren (artists);
|
artists.MouseDownEventHandler += (sender, e) => {
|
songs.TextColor =SkinStyle.Current.MusicTextColor;
|
artists.TextColor = 0xffFE5E00;
|
albums.TextColor =SkinStyle.Current.MusicTextColor;
|
middle.RemoveAll ();
|
var artistsList = new List<string> ();
|
foreach (var musicInfo in MusicInfo.MusicInfoList) {
|
if (!artistsList.Contains (musicInfo.Artist)) {
|
artistsList.Add (musicInfo.Artist);
|
}
|
}
|
foreach (var artist in artistsList) {
|
var rowLa = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
|
};
|
middle.AddChidren (rowLa);
|
|
var musicartistsList = new Button {
|
Height = Application.GetRealHeight (100),
|
Text = artist,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (20),
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
rowLa.AddChidren (musicartistsList);
|
|
musicartistsList.MouseUpEventHandler += (sender1, e1) => {
|
MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load));
|
A31MusicSoAaAl a31SoAaAl = new A31MusicSoAaAl ();
|
MainPage.MainFrameLayout.AddChidren (a31SoAaAl);
|
var musicInfoList = new List<MusicInfo> ();
|
for (int i = 0; i < MusicInfo.MusicInfoList.Count; i++) {
|
if (MusicInfo.MusicInfoList [i].Artist == musicartistsList.Text.ToString ()) {
|
musicInfoList.Add (MusicInfo.MusicInfoList [i]);
|
}
|
}
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
a31SoAaAl.Show (a31, artist, musicInfoList);
|
});
|
|
});
|
|
};
|
}
|
};
|
|
//专辑
|
albums = new Button {
|
Width = Application.GetRealWidth (640 / 3),
|
Height = Application.GetRealHeight (100),
|
X = artists.Right,
|
TextID = MyInternationalizationString.Musicalbum,
|
TextSize = 18,
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
frameLayout.AddChidren (albums);
|
albums.MouseDownEventHandler += (sender, e) => {
|
songs.TextColor =SkinStyle.Current.MusicTextColor;
|
artists.TextColor = SkinStyle.Current.MusicTextColor;
|
albums.TextColor = 0xffFE5E00;
|
|
middle.RemoveAll ();
|
var albumslist = new List<string> ();
|
foreach (var albumsmusic in MusicInfo.MusicInfoList) {
|
if (!albumslist.Contains (albumsmusic.Album)) {
|
albumslist.Add (albumsmusic.Album);
|
}
|
}
|
|
foreach (var album in albumslist) {
|
var rowalbum = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
|
};
|
middle.AddChidren (rowalbum);
|
|
var btnmusicalbum = new Button {
|
Height = Application.GetRealHeight (100),
|
Text = album==""?"Unkown":album,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (20),
|
TextColor = SkinStyle.Current.MusicTextColor,
|
};
|
rowalbum.AddChidren (btnmusicalbum);
|
|
btnmusicalbum.MouseUpEventHandler += (sender1, e1) => {
|
|
MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load));
|
A31MusicSoAaAl a31MusicSoAaAl = new A31MusicSoAaAl ();
|
MainPage.MainFrameLayout.AddChidren (a31MusicSoAaAl);
|
var albumMusiclist = new List<MusicInfo> ();
|
for (int i = 0; i < MusicInfo.MusicInfoList.Count; i++) {
|
if (MusicInfo.MusicInfoList [i].Album == btnmusicalbum.Text.ToString ()) {
|
albumMusiclist.Add (MusicInfo.MusicInfoList [i]);
|
}
|
}
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
a31MusicSoAaAl.Show (a31, album, albumMusiclist);
|
});
|
|
});
|
};
|
|
}
|
};
|
|
System.Threading.Tasks.Task.Run (() => {
|
for (int i = 0; i < buttonList.Count; i++) {
|
try {
|
if (isExited) {
|
return;
|
}
|
var button = buttonList [i];
|
var album = button.GetTagByKey ("Album");
|
var artist = button.GetTagByKey ("Artist");
|
if (album == null || artist == null) {
|
continue;
|
}
|
var filePath = Shared.IO.FileUtils.DownLoadImageFormBaidu (album.ToString (), artist.ToString ());
|
if (filePath != null) {
|
Application.RunOnMainThread (() => {
|
button.UnSelectedImagePath = filePath;
|
});
|
}
|
} catch {
|
|
}
|
}
|
});
|
|
}
|
|
public static void pushList(A31MusicModel a31, MusicInfo musicInfo, string listName)
|
{
|
//最大发送的条数
|
int maxCount = 50;
|
//找出当前点击音乐的索引
|
int statIndex = A31MusicModel.Current.CurrentPlayMusicInfoList.FindIndex ((obj) => { return obj == musicInfo; });
|
//点击后面还有多少条音乐
|
int count = A31MusicModel.Current.CurrentPlayMusicInfoList.Count - statIndex;
|
int endIndex = 0;
|
if (maxCount < count) {
|
//如果后面的音乐大于最大数,设置后面数据的最大索引
|
endIndex = statIndex + maxCount - 1;
|
} else {
|
//如果后面数据不多,就用总数减去最大条数,得到开始索引
|
statIndex = A31MusicModel.Current.CurrentPlayMusicInfoList.Count - maxCount - 1;
|
endIndex = A31MusicModel.Current.CurrentPlayMusicInfoList.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>");
|
sb.AppendLine ("<PlayList>");
|
sb.AppendLine ("<ListName>" + listName + "</ListName>");
|
sb.AppendLine ("<ListInfo>");
|
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 playNumber = 1;
|
for (int trackNumber = 1, index = statIndex; index <= endIndex; trackNumber++, index++) {
|
var tempMusicInfo = a31.CurrentPlayMusicInfoList [index];
|
//找出当前音乐播放的序号
|
if (musicInfo == tempMusicInfo) {
|
playNumber = trackNumber;
|
}
|
|
// if (tempMusicInfo.SourceType == "Local") {
|
// tempMusicInfo.URL = "http://" + new NetWiFi ().IpAddress + ":" + com.hdl.on.Server.Port + "/" + tempMusicInfo.ID;
|
// }
|
// tempMusicInfo.URL = System.Security.SecurityElement.Escape (tempMusicInfo.URL);
|
|
// 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 ("<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 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;" + 1 + "&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;" + 1 + "&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;" + tempMusicInfo.Duration + "&quot;&gt;" + tempMusicInfo.URL + "&lt;/res&gt;");
|
// sb.AppendLine ("&lt;dc:title&gt;" + 1+ "&lt;/dc:title&gt;");
|
// sb.AppendLine ("&lt;dc:creator&gt;DJ Sanny J&lt;/dc:creator&gt;");
|
// sb.AppendLine ("&lt;upnp:artist&gt;" + 1 + "&lt;/upnp:artist&gt;");
|
// sb.AppendLine ("&lt;upnp:album&gt;" + 1 + "&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>" + 1+ "</Id>");
|
// sb.AppendLine ("<Source>iPhone5s_ttpod_Local</Source>");
|
// sb.AppendLine ("<Key>" + tempMusicInfo.URL + "</Key>");
|
// sb.AppendLine ("</Track" + trackNumber + ">");
|
//}
|
|
if (tempMusicInfo.SourceType == "Local") {
|
tempMusicInfo.URL = "http://" + new NetWiFi ().IpAddress + ":" + com.hdl.on.Server.Port + "/" + tempMusicInfo.ID;
|
}
|
tempMusicInfo.URL = System.Security.SecurityElement.Escape (tempMusicInfo.URL);
|
|
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 ("<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 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;" + index + "&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;" + tempMusicInfo.Duration + "&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;" + 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>" + index + "</Id>");
|
sb.AppendLine ("<Source>iPhone5s_ttpod_Local</Source>");
|
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 (a31.IPAddress, a31.Port, "CreateQueue", sb.ToString ());
|
//sendMusicLists(a31.IPAddress, a31.Port, "AppendTracksInQueue", sb.ToString().Replace("CreateQueue", "AppendTracksInQueue"));
|
|
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>" + listName + "</QueueName>");
|
playString.AppendLine ("<Index>" + playNumber + "</Index>");
|
playString.AppendLine ("</u:PlayQueueWithIndex>");
|
playString.AppendLine ("</s:Body>");
|
playString.AppendLine ("</s:Envelope>");
|
|
play (a31.IPAddress, a31.Port, playString.ToString ());
|
|
}
|
|
static void sendMusicLists (string ip, int port, string soapAction, string listInfo)
|
{
|
Shared.Net.MyWebClient webClient = new Shared.Net.MyWebClient ();
|
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 { }
|
|
}
|
|
static void play (string ip, int port, string info)
|
{
|
Shared.Net.MyWebClient webClient = new Shared.Net.MyWebClient ();
|
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 { }
|
}
|
|
}
|
}
|