JLChen
2020-06-04 6d55af8792cf8fbef0055e677b900fc352dba9a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
using System;
using System.Collections.Generic;
using System.Text;
using Shared;
using Shared.SimpleControl;
using Shared.SimpleControl.Phone;
using System.Xml;
using Shared.SimpleControl.R;
using SmartHome.UI.SimpleControl.Phone.Music;
using System.Security;
using SmartHome;
 
namespace Shared.SimpleControl.Phone.Music
{
    /// <summary>
    /// 当前播放列表
    /// </summary>
    class A31PlayList : FrameLayout
    {
        VerticalScrolViewLayout verticalScrolViewLayout;
        List<Button> buttonList = new List<Button> (100);
        Button btnListName;
        string listName;
        public void InitFace ()
        {
            this.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,
            };
            this.AddChidren (topFrameLayout);
 
            btnListName = new Button {
                TextID = MyInternationalizationString.Musicplaylist,
                TextColor=SkinStyle.Current.MusicTextColor,
            };
            topFrameLayout.AddChidren (btnListName);
 
            var back = new Button {
                Width = Application.GetRealWidth (72),
                Height = Application.GetRealHeight (89),
                X = Application.GetRealWidth (-1),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/PlayBack.png",
            };
            back.MouseDownEventHandler += (sender, e) => {
                this.RemoveFromParent ();
            };
            topFrameLayout.AddChidren (back);
 
            verticalScrolViewLayout = new VerticalScrolViewLayout {
                Height = Application.GetRealHeight (Application.DesignHeight - 136),
                Y = topFrameLayout.Bottom,
                BackgroundColor =SkinStyle.Current.MusicVerticalScrolViewLayout,
            };
            AddChidren (verticalScrolViewLayout);
 
            btnListName.Text = Language.StringByID (MyInternationalizationString.Musicplaylist);
        }
 
        public override void RemoveFromParent ()
        {
            base.RemoveFromParent ();
            if (readPlayListThread != null && readPlayListThread.IsAlive) {
                readPlayListThread.Abort ();
            }
            if (readImageThread != null && readImageThread.IsAlive) {
                readImageThread.Abort ();
            }
            if (updateSelectedMusicThread != null && updateSelectedMusicThread.IsAlive) {
                updateSelectedMusicThread.Abort ();
            }
        }
 
        void addView ()
        {
            verticalScrolViewLayout.RemoveAll ();
            buttonList.Clear ();
            for (int i = 0; i < A31MusicModel.Current.CurrentPlayMusicInfoList.Count; i++) {
                var musicInfo = A31MusicModel.Current.CurrentPlayMusicInfoList [i];
                var rowsong = new RowLayout {
                    Height = Application.GetRealHeight (100),
                    LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
                };
                verticalScrolViewLayout.AddChidren (rowsong);
 
                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",
                };
                rowsong.AddChidren (title);
 
                var path = "MusicImage/AlbumArtistImage_";
                musicInfo.Album = musicInfo.Album == null ?"": musicInfo.Album;
                musicInfo.Artist = musicInfo.Artist == null ?"": musicInfo.Artist.Split ('/') [0] ;
 
                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 song = new Button {
                    Width = Application.GetRealWidth (400),
                    Text = musicInfo.Title,
                    Height = Application.GetRealHeight (50),
                    TextAlignment = TextAlignment.BottomLeft,
                    X = Application.GetRealWidth (100),
                    Tag = musicInfo,
                    TextColor = A31MusicModel.Current.A31PlayStatus.Title == musicInfo.Title ? 0xffFE5E00 : SkinStyle.Current.MusicTextColor,
                };
                rowsong.AddChidren (song);
 
 
                var artist = new Button {
                    Width = Application.GetRealWidth (400),
                    Height = Application.GetRealHeight (50),
                    Text = musicInfo.Artist + "-" + musicInfo.Album,
                    TextAlignment = TextAlignment.TopLeft,
                    X = Application.GetRealWidth (100),
                    Y = song.Bottom,
                    Tag = musicInfo,
                    //TextColor = 0x75ffffff,
                    TextColor = SkinStyle.Current.MusicArtistTextColor,
                };
                rowsong.AddChidren (artist);
 
                EventHandler<MouseEventArgs> musics = (sender, e) => {
                    rowsong.BackgroundColor = 0xffFE5E00;
                    System.Threading.Tasks.Task.Run (() => {
                        System.Threading.Thread.Sleep (50);
                        Application.RunOnMainThread (() => {
                            this.RemoveFromParent ();
                            A31MusicModel.Current.A31PlayStatus.Title = song.Text;
                            System.Threading.Tasks.Task.Run (() => {
                                listplay (listName, song.Tag as MusicInfo);
                                //if (A31MusicModel.Current.A31PlayStatus.playSource == "Tidal") {
                                //    A31NewPage.tidalpushList (song.Tag as MusicInfo, A31MusicModel.Current.CurrentPlayMusicInfoList);
                                //} else {
                                //    listplay (listName, song.Tag as MusicInfo);
                                //}
                            });
                        });
                    });
                };
                song.MouseUpEventHandler += musics;
                artist.MouseUpEventHandler += musics;
                title.MouseUpEventHandler += musics;
 
 
                var del = new Button {
                    TextID = MyInternationalizationString.Musicdel,
                    BackgroundColor = 0xFFFF0000,
                    Tag = A31MusicModel.Current.CurrentPlayMusicInfoList [i].ID,
                };
                //rowsong.AddRightView(del);
                del.MouseUpEventHandler += (sender, e) => {
                    for (int j = 0; j < A31MusicModel.Current.CurrentPlayMusicInfoList.Count; j++) {
                        if (A31MusicModel.Current.CurrentPlayMusicInfoList [j].ID == del.Tag.ToString ()) {
                            A31MusicModel.Current.CurrentPlayMusicInfoList.RemoveAt (j);
                            break;
                        }
                    }
                    //这里需要更新一下要发送的列表信息
                    rowsong.RemoveFromParent ();
                };
            }
        }
 
        public void Musiclist (string listName)
        {
            this.listName = listName;
            addView ();
            updateSelectedMusic ();
            readImage ();
            readPlayList ();
        }
 
        List<MusicInfo> playList ()
        {
            var list = new List<MusicInfo> ();
            try {
                var playString =CurrentPlayList ();
                var se = System.Security.SecurityElement.FromString (playString);
                while (se.Children != null) {
                    se = se.Children [0] as System.Security.SecurityElement;
                }
 
                foreach (SecurityElement track in SecurityElement.FromString (se.Text).SearchForChildByTag ("Tracks").Children) {
                    MusicInfo musicInfo = new MusicInfo ();
                    musicInfo.URL = track.SearchForTextOfTag ("URL").Replace ("&", "&amp;amp;");
                    var metadata = track.SearchForTextOfTag ("Metadata");
                    musicInfo.SourceName = track.SearchForTextOfTag ("Source");
                    if (string.IsNullOrEmpty (metadata)) {
                        continue;
                    }
                    if (A31MusicModel.IsJson (metadata)) {
                        var qqSong = Newtonsoft.Json.JsonConvert.DeserializeObject<A31QQSong> (metadata);
                        musicInfo.Album = qqSong.album;
                        musicInfo.Title = qqSong.title;
                        musicInfo.Artist = qqSong.creator;
                    } else {
                        metadata = metadata.Replace ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "").Replace ("&", "&amp;amp;");
                        var item = SecurityElement.FromString (metadata).SearchForChildByTag ("item");
                        musicInfo.Title = item.SearchForTextOfTag ("dc:title");
                        musicInfo.Artist = item.SearchForTextOfTag ("upnp:artist");
                        musicInfo.Album = item.SearchForTextOfTag ("upnp:album");
                        musicInfo.Duration = item.SearchForTextOfTag ("res");
                        musicInfo.AlbumId = item.SearchForTextOfTag ("song:albumid");
                    }
                    list.Add (musicInfo);
                }
            } catch { }
            return list;
        }
 
        /// <summary>
        /// 定时更新当前播放音乐
        /// </summary>
        System.Threading.Thread updateSelectedMusicThread;
        void updateSelectedMusic ()
        {
            updateSelectedMusicThread = new System.Threading.Thread (() => {
                while (this.Parent != null) {
                    System.Threading.Thread.Sleep (1000);
                    Shared.Application.RunOnMainThread (() => {
                        try {
                            for (int i = 0; i < verticalScrolViewLayout.ChildrenCount; i++) {
                                RowLayout view = (RowLayout)verticalScrolViewLayout.GetChildren (i);
                                var songName = (Button)view.GetChildren (1);
                                if (A31MusicModel.Current.A31PlayStatus.Title == songName.Text) {
                                    songName.TextColor = 0xffFE5E00;
                                } else {
                                    songName.TextColor = SkinStyle.Current.MusicTextColor;
                                }
                            }
                        } catch { }
 
                    });
                }
            });
            updateSelectedMusicThread.Start ();
        }
        /// <summary>
        /// 定时读取图片线程
        /// </summary>
        System.Threading.Thread readImageThread;
        void readImage ()
        {
            readImageThread = new System.Threading.Thread (() => {
 
                for (int i = 0; i < buttonList.Count;i++) {
                    var button = buttonList [i];
                    var album = button.GetTagByKey ("Album");
                    var artist = button.GetTagByKey ("Artist");
                    if (album.ToString()=="" && artist.ToString()=="") {
                        continue;
                    }
                
                    var filePath = Shared.IO.FileUtils.DownLoadImageFormBaidu (album.ToString (), artist.ToString ());
                    if (filePath != null) {
                        Application.RunOnMainThread (() => {
                            button.UnSelectedImagePath = filePath;
                        });
                    }
                }
            });
            readImageThread.Start ();
        }
        /// <summary>
        ///  定时读取Tida音乐列表
        /// </summary>
        System.Threading.Thread readPlayListThread;
        void readPlayList ()
        {
            if (A31MusicModel.Current.A31PlayStatus.playSource == "Tidal") {
                readPlayListThread = new System.Threading.Thread (() => {
                    while (true) {
                        System.Threading.Thread.Sleep (1000);
                        var list = playList ();
                        if (list.Count <= A31MusicModel.Current.CurrentPlayMusicInfoList.Count) {
                            continue;
                        }
                        A31MusicModel.Current.CurrentPlayMusicInfoList = list;
                        Application.RunOnMainThread (() => {
                            addView ();
                        });
                    }
                });
                readPlayListThread.Start ();
            }
        }
 
        public void pushList (MusicInfo musicInfo, string listName, string sourceName)
        {
            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 ("&lt;PlayList&gt;");
            sb.AppendLine ("&lt;ListName&gt;" + listName + "&lt;/ListName&gt;");
            sb.AppendLine ("&lt;ListInfo&gt;");
            sb.AppendLine ("&lt;SourceName&gt;" + sourceName + "&lt;/SourceName&gt;");
            sb.AppendLine ("&lt;MarkSearch&gt;0&lt;/MarkSearch&gt;");
            sb.AppendLine ("&lt;TrackNumber&gt;" + A31MusicModel.Current.CurrentPlayMusicInfoList.Count + "&lt;/TrackNumber&gt;");
            sb.AppendLine ("&lt;Quality&gt;0&lt;/Quality&gt;");
            sb.AppendLine ("&lt;UpdateTime&gt;5367&lt;/UpdateTime&gt;");
            sb.AppendLine ("&lt;LastPlayIndex&gt;2&lt;/LastPlayIndex&gt;");
            sb.AppendLine ("&lt;SwitchPageMode&gt;0&lt;/SwitchPageMode&gt;");
            sb.AppendLine ("&lt;CurrentPage&gt;0&lt;/CurrentPage&gt;");
            sb.AppendLine ("&lt;TotalPages&gt;0&lt;/TotalPages&gt;");
            sb.AppendLine ("&lt;/ListInfo&gt;");
            sb.AppendLine ("&lt;Tracks&gt;");
 
            int number = 1;
            int i = 0;
            foreach (var tempMusicInfo in A31MusicModel.Current.CurrentPlayMusicInfoList) {
 
                i++;
                if (musicInfo == tempMusicInfo) {
                    number = i;
                }
 
                sb.AppendLine ("&lt;Track" + i + "&gt;");
                sb.AppendLine ("&lt;URL&gt;" + tempMusicInfo.URL + "&lt;/URL&gt;");
                sb.AppendLine ("&lt;Metadata&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;");
                sb.AppendLine ("&amp;lt;DIDL-Lite xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot; xmlns:upnp=&amp;quot;urn:schemas-upnp-org:metadata-1-0/upnp/&amp;quot; xmlns:song=&amp;quot;www.wiimu.com/song/&amp;quot; xmlns=&amp;quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&amp;quot;&amp;gt;");
                sb.AppendLine ("&amp;lt;upnp:class&amp;gt;object.item.audioItem.musicTrack&amp;lt;/upnp:class&amp;gt;");
                sb.AppendLine ("&amp;lt;item id=&amp;quot;0&amp;quot;&amp;gt;");
                sb.AppendLine ("&amp;lt;song:subid&amp;gt;&amp;lt;/song:subid&amp;gt;");
                sb.AppendLine ("&amp;lt;song:description&amp;gt;unknown&amp;lt;/song:description&amp;gt;");
                sb.AppendLine ("&amp;lt;song:skiplimit&amp;gt;6&amp;lt;/song:skiplimit&amp;gt;");
                sb.AppendLine ("&amp;lt;song:id&amp;gt;" + tempMusicInfo.ID + "&amp;lt;/song:id&amp;gt;");
                sb.AppendLine ("&amp;lt;song:like&amp;gt;0&amp;lt;/song:like&amp;gt;");
                sb.AppendLine ("&amp;lt;song:singerid&amp;gt;0&amp;lt;/song:singerid&amp;gt;");
                sb.AppendLine ("&amp;lt;song:albumid&amp;gt;" + tempMusicInfo.AlbumId + "&amp;lt;/song:albumid&amp;gt;");
                sb.AppendLine ("&amp;lt;res protocolInfo=&amp;quot;http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;&amp;quot; duration=&amp;quot;" + tempMusicInfo.Duration + "&amp;quot;&amp;gt;" + tempMusicInfo.URL + "&amp;lt;/res&amp;gt;");
                sb.AppendLine ("&amp;lt;dc:title&amp;gt;" + tempMusicInfo.Title + "&amp;lt;/dc:title&amp;gt;");
                sb.AppendLine ("&amp;lt;dc:creator&amp;gt;DJ Sanny J&amp;lt;/dc:creator&amp;gt;");
                sb.AppendLine ("&amp;lt;upnp:artist&amp;gt;" + tempMusicInfo.Artist + "&amp;lt;/upnp:artist&amp;gt;");
                sb.AppendLine ("&amp;lt;upnp:album&amp;gt;" + tempMusicInfo.Album + "&amp;lt;/upnp:album&amp;gt;");
                sb.AppendLine ("&amp;lt;upnp:albumArtURI&amp;gt;unknown&amp;lt;/upnp:albumArtURI&amp;gt;");
                sb.AppendLine ("&amp;lt;/item&amp;gt;");
                sb.AppendLine ("&amp;lt;/DIDL-Lite&amp;gt;");
                sb.AppendLine ("&lt;/Metadata&gt;");
                sb.AppendLine ("&lt;Source&gt;" + tempMusicInfo.SourceName + "&lt;/Source&gt;");
                sb.AppendLine ("&lt;/Track" + i + "&gt;");
 
            }
            sb.AppendLine ("&lt;/Tracks&gt;");
            sb.AppendLine ("&lt;/PlayList&gt;");
            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>" + 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)
        {
            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 { }
        }
 
        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 { }
        }
 
        void listplay (string listName, MusicInfo musicInfo)
        {
            StringBuilder playstrings = new StringBuilder ();
            int number = 1;
            int i = 0;
            foreach (var tempMusicInfo in A31MusicModel.Current.CurrentPlayMusicInfoList) {
                i++;
                if (musicInfo == tempMusicInfo) {
                    number = i;
                }
            }
            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>");
 
            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://" + A31MusicModel.Current.IPAddress + ":" + A31MusicModel.Current.Port + "/upnp/control/PlayQueue1"), "POST", Encoding.UTF8.GetBytes (playstrings.ToString ()));
                var s = System.Text.Encoding.UTF8.GetString (recevieBytes, 0, recevieBytes.Length);
            } catch { }
        }
 
 
        /// <summary>
        /// 获取当前播放的列表
        /// </summary>
         string CurrentPlayList ()
        {
            StringBuilder getPlayList = new 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>");
 
            Shared.Net.MyWebClient webClient = new Shared.Net.MyWebClient ();
            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://" + A31MusicModel.Current.IPAddress + ":" + A31MusicModel.Current.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;
        }
 
    }
}