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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
using System;
using System.Collections.Generic;
using System.Text;
using Shared;
using Shared.SimpleControl.Phone;
using Shared.SimpleControl;
using Shared.SimpleControl.R;
 
namespace Shared.SimpleControl.Phone.Music
{
    /// <summary>
    /// SD卡和Nas播放的界面 
    /// </summary>
    class PlayPage : FrameLayout
    {
        void showSourcePage ()
        {
            switch (currentMusicModel.SourceID) {
            //sd
            case "1":
                #region
                sourceName.TextID = MyInternationalizationString.SDcard;
                like.Alpha = 1;
                like.Enable = true;
 
                list.Alpha = 1;
                list.Enable = true;
 
                prve.Alpha = 1;
                prve.Enable = true;
 
                next.Alpha = 1;
                next.Enable = true;
 
                mode.Alpha = 1;
                mode.Enable = true;
                #endregion
                break;
 
            //ftp
            case "2":
                #region
                sourceName.TextID = MyInternationalizationString.NAS;
                like.Alpha = 1;
                like.Enable = true;
 
                list.Alpha = 1;
                list.Enable = true;
 
                prve.Alpha = 1;
                prve.Enable = true;
 
                next.Alpha = 1;
                next.Enable = true;
 
                mode.Alpha = 1;
                mode.Enable = true;
                #endregion
                break;
 
            //cd
            case "6":
                #region
                sourceName.TextID = MyInternationalizationString.MusicCD;
                like.Alpha = 0.5f;
                like.Enable = false;
 
                list.Alpha = 0.5f;
                list.Enable = false;
 
                prve.Alpha = 0.5f;
                prve.Enable = false;
 
                next.Alpha = 0.5f;
                next.Enable = false;
 
                mode.Alpha = 0.5f;
                mode.Enable = false;
                #endregion
                break;
 
            //蓝牙 
            case "8":
                #region
                sourceName.TextID = MyInternationalizationString.Musicbluetooth;
                like.Alpha = 0.5f;
                like.Enable = false;
 
                list.Alpha = 0.5f;
                list.Enable = false;
 
                prve.Alpha = 1;
                prve.Enable = true;
 
                next.Alpha = 1;
                next.Enable = true;
 
                mode.Alpha = 0.5f;
                mode.Enable = false;
                #endregion
                break;
 
            //光纤
            case "9":
                #region
                sourceName.TextID = MyInternationalizationString.MusicFD;
                like.Alpha = 0.5f;
                like.Enable = false;
 
                list.Alpha = 0.5f;
                list.Enable = false;
 
                prve.Alpha = 0.5f;
                prve.Enable = false;
 
                next.Alpha = 0.5f;
                next.Enable = false;
 
                mode.Alpha = 0.5f;
                mode.Enable = false;
                #endregion
                break;
            }
        }
 
        /// <summary>
        /// 1表示SD卡,2表示Nas
        /// </summary>
        public int SourceId {
            set {
                if (currentMusicModel.SourceID != value.ToString ()) {
                    currentMusicModel.SourceID = value.ToString ();
                    send ("*Z1SRC" + value);
                }
            }
        }
 
        /// <summary>
        /// 当前源的名称
        /// </summary>
        Button sourceName = new Button {
            Width = Application.GetRealWidth (200),
            Height = Application.GetRealHeight (60),
            X = Application.GetRealWidth (230),
            Y = Application.GetRealHeight (175 - 130),
            };
        /// <summary>
        /// 停止/播放;
        /// </summary>
        Button btnPlay = new Button {
            Width = Application.GetRealWidth (159),
            Height = Application.GetRealHeight (127),
            X = Application.GetRealWidth (260),
            Gravity = Gravity.CenterVertical,
            UnSelectedImagePath = "MusicIcon/Playplay.png",
            SelectedImagePath = "MusicIcon/playmusicplaySelected.png",
        };
        /// <summary>
        ///当前播放音乐时间
        /// </summary>
        Button btnMusicplayTime = new Button {
            Width = Application.GetRealWidth (126),
            Height = Application.GetRealHeight (126),
            X = Application.GetRealWidth (10),
            Y = Application.GetRealHeight (820 - 130),
        };
        /// <summary>
        /// 音乐总时间
        /// </summary>
        Button btnTotalMusicTime = new Button {
            Width = Application.GetRealWidth (126),
            Height = Application.GetRealHeight (126),
            X = Application.GetRealWidth (520),
            Y = Application.GetRealHeight (820 - 130),
 
        };
        /// <summary>
        /// 播放音乐时间进度条
        /// </summary>
        Button progressMaxButton = new Button {
            Height = Application.GetRealHeight (4),
            Radius = (uint)Application.GetRealHeight (2),
            Gravity = Gravity.CenterVertical,
            BackgroundColor = 0xff525252,
        };
        /// <summary>
        /// 播放进度
        /// </summary>
        Button progressButton = new Button {
            Width = 0,
            Height = Application.GetRealHeight (4),
            Radius = (uint)Application.GetRealHeight (2),
            Gravity = Gravity.CenterVertical,
            BackgroundColor = 0xffFE5E00,
        };
 
        /// <summary>
        /// 当前播放的音乐名称 
        /// </summary>
        Button title = new Button {
            Width = Application.GetMinRealAverage (350),
            Height = Application.GetMinRealAverage (60),
            TextSize = 15,
            X = Application.GetRealWidth (150),
            Y = Application.GetRealHeight (747 - 130),
        };
        /// <summary>
        /// 静音图标
        /// </summary>
        Button btnMute = new Button {
            Width = Application.GetRealWidth (107),
            Height = Application.GetRealHeight (127),
            X = Application.GetRealWidth (15),
            Gravity = Gravity.CenterVertical,
            UnSelectedImagePath = "MusicIcon/PlayMute.png",
            SelectedImagePath = "MusicIcon/PlayMuteSelected.png",
        };
 
 
        /// <summary>
        /// 音量进度条
        /// </summary>
        HorizontalSeekBar horizontalSeekBarVol = new HorizontalSeekBar {
            Width = Application.GetRealWidth (490 - 26),
            Height = Application.GetRealHeight (50),
            Radius = (uint)Application.GetRealHeight (25),
            X = Application.GetRealWidth (13),
            Gravity = Gravity.CenterVertical,
            BackgroundColor = 0xFF525252,
            ProgressColor = 0xffFE5E00,
            Max = 79,
        };
 
        /// <summary>
        ///模式图标,1单曲播放,2单曲循环,3连续播放,4连播循环
        /// </summary>
        Button mode = new Button {
            Width = Application.GetRealWidth (94),
            Height = Application.GetRealHeight (82),
            X = Application.GetRealWidth (18),
            Y = Application.GetRealHeight (732 - 130),
        };
 
        /// <summary>
        /// 收藏图标
        /// </summary>
        Button like = new Button {
            Width = Application.GetRealWidth (106),
            Height = Application.GetRealHeight (103),
            X = Application.GetRealWidth (10),
            Y = Application.GetRealHeight (157 - 130),
            UnSelectedImagePath = "MusicIcon/PlayLike.png",
            SelectedImagePath = "MusicIcon/PlayLikeSelected.png",
        };
        /// <summary>
        /// 显示播放列表
        /// </summary>
        Button list = new Button {
            Width = Application.GetRealWidth (106),
            Height = Application.GetRealHeight (103),
            X = Application.GetRealWidth (540),
            Y = Application.GetRealHeight (727 - 130),
            UnSelectedImagePath = "MusicIcon/PlayList.png",
        };
 
        /// <summary>
        /// 上一曲
        /// </summary>
        Button prve = new Button {
            Width = Application.GetRealWidth (126),
            Height = Application.GetRealHeight (126),
            X = Application.GetRealWidth (127),
            Gravity = Gravity.CenterVertical,
            UnSelectedImagePath = "MusicIcon/PlayPrve.png",
            SelectedImagePath = "MusicIcon/PlayPrveSelected.png",
        };
 
        /// <summary>
        /// 下一曲
        /// </summary>
        Button next = new Button {
            Width = Application.GetRealWidth (126),
            Height = Application.GetRealHeight (126),
            X = Application.GetRealWidth (430),
            Gravity = Gravity.CenterVertical,
            UnSelectedImagePath = "MusicIcon/PlayNext.png",
            SelectedImagePath = "MusicIcon/PlayNextSelected.png",
        };
 
        /// <summary>
        /// 当前界面对象
        /// </summary>
        static PlayPage currentPlayMusic;
 
        /// <summary>
        /// 当前音乐对象
        /// </summary>
        MusicModel currentMusicModel;
 
        /// <summary>
        /// 加载音乐播放界面
        /// </summary>
        /// <param name="musicModel">当前音乐播放对象</param>
        /// <param name="playListmusic">当前播放的音乐列表</param>
        /// <param name="sourceId">源ID,SD卡及Ftp源</param>
        public void Show (MusicModel musicModel, List<KeyAndValue> playListmusic)
        {
            if (currentMusicModel != null) {
                currentPlayMusic.RemoveFromParent ();
            }
            currentPlayMusic = this;
            currentMusicModel = musicModel;
 
            //读取当前的音乐状态
            readStatus ();
 
            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 back = new Button {
                Width = Application.GetMinRealAverage (72),
                Height = Application.GetMinRealAverage (89),
                X = Application.GetRealWidth (10),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/PlayBack.png",
            };
            topFrameLayout.AddChidren (back);
            back.MouseDownEventHandler += (sender, o) => {
                currentPlayMusic = null;
                //退出界面的时候,从父控件里移除掉
                RemoveFromParent ();
            };
 
            topFrameLayout.AddChidren (new Button {
                Width = Application.GetMinRealAverage (300),
                Height = Application.GetMinRealAverage (60),
                Text = musicModel.Name,
                TextSize = 15,
                Gravity = Gravity.Center,
                TextColor=SkinStyle.Current.MusicTextColor,
            });
 
            var set = new Button {
                Width = Application.GetRealWidth (76),
                Height = Application.GetRealHeight (66),
                X = Application.GetRealWidth (550),
                UnSelectedImagePath = "MusicIcon/PlayMusicset.png",
                Gravity = Gravity.CenterVertical,
                Tag = musicModel,
            };
            if (musicModel.MusicType == 1) {
                topFrameLayout.AddChidren (set);
            }
 
            set.MouseDownEventHandler += (sender, e) => {
                SourcePage sourcePage = new SourcePage { };
                MainPage.MainFrameLayout.AddChidren (sourcePage);
                sourcePage.Show ((MusicModel)set.Tag);
            };
 
            var middleFrameLayout = new FrameLayout () {
                Height = Application.GetRealHeight (1000+ 100),
                Y = topFrameLayout.Bottom,
                BackgroundImagePath = "MusicIcon/PlayBackgroun.png"
            };
            AddChidren (middleFrameLayout);
            topFrameLayout.BringToFront ();//隐藏底层
 
            if (musicModel.MusicType == 1) {
                middleFrameLayout.AddChidren (sourceName);
            }
 
            var portrait = new Button {
                Width = Application.GetRealWidth (392),
                Height = Application.GetRealHeight (392),
                X = Application.GetRealWidth (120),
                Y = Application.GetRealHeight (280 - 130),
                UnSelectedImagePath = "MusicIcon/PlayPortrait.png",
            };
            middleFrameLayout.AddChidren (portrait);
 
            like.Tag = musicModel;
            like.MouseDownEventHandler += (sener, o) => {
                like.IsSelected = !like.IsSelected;
                string number = currentMusicModel.curTypeNumber + currentMusicModel.curListNumber + currentMusicModel.curSongNumber;
                if (like.IsSelected) {
                    if (null == currentMusicModel.LovePlayList.Find ((song) => { return song.number == number; })) {
                        //如果没有找到,就加入
                        currentMusicModel.LovePlayList.Add (new KeyAndValue {
                            number = number,
                            name = currentMusicModel.curPlayMusicName.Replace (".mp3", "")
                        });
                    }
                } else {
                    for (int i = 0; i < currentMusicModel.LovePlayList.Count; i++) {
                        if (currentMusicModel.LovePlayList [i].number == number) {
                            currentMusicModel.LovePlayList.RemoveAt (i);
                            break;
                        }
                    }
                }
 
                //保存
                string saveRoomUIName = "Room_" + Room.CurrentRoom.Name;
                Shared.IO.FileUtils.WriteFileByBytes (saveRoomUIName,
                 Shared.SimpleControl.CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (Room.CurrentRoom)));
            };
            //middleFrameLayout.AddChidren(like);
            if (musicModel.MusicType == 1) {
                middleFrameLayout.AddChidren (mode);
            }
            mode.MouseDownEventHandler += Mode_MouseDownEventHandler;
 
            middleFrameLayout.AddChidren (title);
 
            list.Tag = musicModel.Name;
            if (musicModel.MusicType == 1) {
                middleFrameLayout.AddChidren (list);
            }
            list.MouseDownEventHandler += (sender, e) => {
                Button button = (Button)sender;
                ListPage listMusic = new ListPage {
                    Width = LayoutParams.MatchParent,
                    Height = LayoutParams.MatchParent,
                };
                MainPage.MainFrameLayout.AddChidren (listMusic);
 
                if (currentMusicModel.SourceID == "1") {
                    playListmusic = musicModel.SDCardSongList.FindAll (song => { return song.number.StartsWith (musicModel.curTypeNumber + musicModel.curListNumber); });
                } else if (currentMusicModel.SourceID == "2") {
                    playListmusic = musicModel.NasSongList.FindAll (song => { return song.number.StartsWith (musicModel.curTypeNumber + musicModel.curListNumber); });
                }
                listMusic.Musiclist (musicModel, playListmusic, musicModel.curMusicListName, int.Parse (currentMusicModel.SourceID));
            };
 
            #region    歌曲时间
 
            middleFrameLayout.AddChidren (btnMusicplayTime);
            middleFrameLayout.AddChidren (btnTotalMusicTime);
            var frameLayout1 = new FrameLayout {
                Width = Application.GetRealWidth (400 - 26),
                Height = Application.GetRealHeight (126),
                X = Application.GetRealWidth (150),
                Y = Application.GetRealHeight (820 - 130),
            };
            middleFrameLayout.AddChidren (frameLayout1);
 
            frameLayout1.AddChidren (progressMaxButton);
            frameLayout1.AddChidren (progressButton);
            #endregion
 
            #region    上,下,暂停/播放
            var tempFrameLayout = new FrameLayout {
                Height = Application.GetRealHeight (130),
                Y = Application.GetRealHeight (960 - 130)
            };
            middleFrameLayout.AddChidren (tempFrameLayout);
            tempFrameLayout.AddChidren (prve);
            prve.MouseDownEventHandler += (sender, o) => {
                prve.IsSelected = true;
                send ("*S" + currentMusicModel.SourceID + "PREV");
            };//下
            prve.MouseUpEventHandler += (sender, o) => {
                prve.IsSelected = false;
            };//上
 
            tempFrameLayout.AddChidren (btnPlay);
            btnPlay.MouseDownEventHandler += (sender, o) => {
                btnPlay.IsSelected = !btnPlay.IsSelected;
                if (btnPlay.IsSelected) {
                    if (musicModel.MusicType== 2) {
                        send ("*Z1ON");
                    } else {
                        send ("*S" + currentMusicModel.SourceID + "PLAY");
                    }
                    currentMusicModel.PlayStatus = MusicModel.Status.Play;
                } else {
                    if (musicModel.MusicType == 2) {
                        send ("*Z1OFF");
                    } else {
                        send ("*S" + currentMusicModel.SourceID + "STOP");
                    }
                    currentMusicModel.PlayStatus = MusicModel.Status.Stop;
                }
 
            };
 
            next.MouseDownEventHandler += (sender, o) => {
                next.IsSelected = true;
                send ("*S" + currentMusicModel.SourceID + "NEXT");
            };
            next.MouseUpEventHandler += (sender, o) => {
                next.IsSelected = false;
            };
            tempFrameLayout.AddChidren (next);
            #endregion
 
            #region 音量+,-,静音
            tempFrameLayout.AddChidren (btnMute);
            btnMute.MouseDownEventHandler += (sender, e) => {
                btnMute.IsSelected = !btnMute.IsSelected;
                if (btnMute.IsSelected) {
                    //静音之前先保存之前的音量,为还原音量
                    beforeVol = currentMusicModel.CurVol;
                    send ("*Z1VOL79");
                    currentMusicModel.CurVol = "79";
                } else {
                    send ("*Z1VOL" + beforeVol);
                    currentMusicModel.CurVol = beforeVol;
                }
            };
 
            var btnMusicvol = new Button {
                Width = Application.GetRealWidth (107),
                Height = Application.GetRealHeight (127),
                X = Application.GetRealWidth (540),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/PlayVoice.png",
                SelectedImagePath = "MusicIcon/PlayVoiceSelected.png",
            };
            tempFrameLayout.AddChidren (btnMusicvol);
            btnMusicvol.MouseDownEventHandler += (sender, o) => {
                btnMusicvol.IsSelected = !btnMusicvol.IsSelected;
                if (btnMusicvol.IsSelected) {
                    middleFrameLayout.Y -= Application.GetRealHeight (100);
                } else {
                    middleFrameLayout.Y += Application.GetRealHeight (100);
                }
            };
 
            var ProgFrameLayout = new FrameLayout {
                Width = LayoutParams.MatchParent,
                Height = Application.GetRealHeight (100),
                Y = Application.GetRealHeight (1120 - 130),
            };
            middleFrameLayout.AddChidren (ProgFrameLayout);
 
            var btnMusicvo2 = new Button {
                Width = Application.GetRealWidth (107),
                Height = Application.GetRealHeight (127),
                X = Application.GetRealWidth (15),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/PlayVoice.png",
            };
            ProgFrameLayout.AddChidren (btnMusicvo2);
 
            var frameLayout = new FrameLayout {
                Width = Application.GetRealWidth (490),
                Height = Application.GetRealHeight (50),
                Gravity = Gravity.CenterVertical,
                X = Application.GetRealWidth (120),
            };
            ProgFrameLayout.AddChidren (frameLayout);
            frameLayout.AddChidren (horizontalSeekBarVol);
            horizontalSeekBarVol.ProgressChanged += (sender, p) => {
                send ("*Z1VOL" + (79 - p));
            };
            #endregion
        }
 
        /// <summary>
        /// 模式切换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Mode_MouseDownEventHandler (object sender, MouseEventArgs e)
        {
            Button button = (Button)sender;
            switch (currentMusicModel.playMode) {
            //1单曲播放playModeDanquplay,2单曲循环playModeDDdanquplay,
            //3连续播放playModeshunxuplay,4连播循环playModeliebiaoplay
            case 1:
                currentMusicModel.playMode = 2;
                button.UnSelectedImagePath = "MusicIcon/playModeDDdanquplay.png";
                button.IsSelected = false;
                break;
 
            case 2:
                currentMusicModel.playMode = 3;
                button.UnSelectedImagePath = "MusicIcon/playModeshunxuplay.png";
                button.IsSelected = false;
                break;
 
            case 3:
                currentMusicModel.playMode = 4;
                button.UnSelectedImagePath = "MusicIcon/playModeliebiaoplay.png";
                button.IsSelected = false;
                break;
 
            case 4:
                currentMusicModel.playMode = 1;
                button.UnSelectedImagePath = "MusicIcon/playModeDanquplay.png";
                button.IsSelected = false;
                break;
 
            default:
                currentMusicModel.playMode = 3;
                button.UnSelectedImagePath = "MusicIcon/playModeshunxuplay.png";
                button.IsSelected = false;
                break;
 
            }
            send ("*S" + currentMusicModel.SourceID + "MODE+");
        }
 
        //点击静音之前的音量
        string beforeVol = "30";
 
        /// <summary>
        /// 发送控制命令
        /// </summary>
        /// <param name="command"></param>
        void send (string command)
        {
            //当控制完成时,马上读取状态,会有问题,所以控制后5秒再读取
            MyMusic.dateTime = System.DateTime.Now;
            ////如果不是当前源,就先切换源
            //if (currentMusicModel.SourceID != currentMusicModel.SourceID.ToString())
            //{
            //    Control.ControlBytesSend(Command.ControlMusicModel, currentMusicModel.SubnetID, currentMusicModel.DeviceID, MusicModel.MusiceBytes("*Z1SRC" + sourceId));
            //}
            //发送控制命令
            Control.ControlBytesSend (Command.ControlMusicModel, currentMusicModel.SubnetID, currentMusicModel.DeviceID, MusicModel.MusiceBytes (command), SendCount.Zero);
        }
 
        /// <summary>
        /// 读取音乐状态
        /// </summary>
        void readStatus ()
        {
            System.Threading.Tasks.Task.Run (() => {
                System.DateTime dateTime = System.DateTime.Now.AddSeconds (-5);
 
                while (Parent != null) {
                    //等待1秒,更新界面
                    System.Threading.Thread.Sleep (1000 * 1);
 
                    Application.RunOnMainThread (() => {
                        #region
                        try {
                            showSourcePage ();
 
                            //总共有多少秒
                            int totalSecond = int.Parse (currentMusicModel.musicTime) / 10;
                            //分钟
                            int totalMusicMinute = totalSecond / 60;
                            //秒钟
                            int totalMusicSecond = totalSecond % 60;
 
                            string totalTime = (totalMusicMinute.ToString ().Length < 2 ? "0" + totalMusicMinute.ToString () : totalMusicMinute.ToString ()) + ":" + (totalMusicSecond.ToString ().Length < 2 ? "0" + totalMusicSecond.ToString () : totalMusicSecond.ToString ());
                            btnTotalMusicTime.Text = totalTime;
 
                            title.Text = currentMusicModel.curPlayMusicName.Replace (".mp3", "");
                            horizontalSeekBarVol.Progress = 79 - int.Parse (currentMusicModel.CurVol);
 
                            switch (currentMusicModel.playMode) {
                            #region
                            case 1:
                                mode.UnSelectedImagePath = "MusicIcon/playModeDanquplay.png";
                                break;
                            case 2:
                                mode.UnSelectedImagePath = "MusicIcon/playModeDDdanquplay.png";
                                break;
                            case 3:
                                mode.UnSelectedImagePath = "MusicIcon/playModeshunxuplay.png";
                                break;
                            case 4:
                                mode.UnSelectedImagePath = "MusicIcon/playModeliebiaoplay.png";
                                break;
                            default:
                                mode.UnSelectedImagePath = "MusicIcon/playModeshunxuplay.png";
                                break;
                                #endregion
                            }
 
                            if (currentMusicModel.SourceID == "1") {
                                var likeMusic = currentMusicModel.LovePlayList.Find ((like) => {
                                    return like.number == currentMusicModel.curTypeNumber + currentMusicModel.curListNumber + currentMusicModel.curSongNumber;
                                });
                                //找到当前的播放ID,就说明是收藏音乐
                                like.IsSelected = likeMusic != null;
                            } else if (currentMusicModel.SourceID == "2") {
                                var likeMusic = currentMusicModel.NasSongList.Find ((like) => {
                                    return like.number == currentMusicModel.curTypeNumber + currentMusicModel.curListNumber + currentMusicModel.curSongNumber;
                                });
                                //找到当前的播放ID,就说明是收藏音乐
                                like.IsSelected = likeMusic != null;
                            }
 
                            btnMute.IsSelected = currentMusicModel.CurVol == "79" ? true : false;
                            if (currentMusicModel.PlayStatus == MusicModel.Status.Play) {
                                btnPlay.IsSelected = true;
                                //如果在播放,时间就不断变化
                                //当前播放音乐时间
                                int playSecond = int.Parse (currentMusicModel.musicPalyTime) / 10 + (int)(DateTime.Now - currentMusicModel.LastDateTime).TotalSeconds;
                                //分钟
                                int playMusicMinute = playSecond / 60;
                                //秒钟
                                int playMusicSecond = playSecond % 60;
                                string playTime = (playMusicMinute.ToString ().Length < 2 ? "0" + playMusicMinute.ToString () : playMusicMinute.ToString ()) + ":" + (playMusicSecond.ToString ().Length < 2 ? "0" + playMusicSecond.ToString () : playMusicSecond.ToString ());
                                btnMusicplayTime.Text = playTime;
                                if (totalSecond == 0) {
                                    progressButton.Width = 0;
                                } else {
                                    progressButton.Width = (int)(playSecond * 1.0 / totalSecond * progressMaxButton.Width);
                                }
                            } else {
                                //停止状态
                                btnPlay.IsSelected = false;
                                progressButton.Width = 0;
                                btnMusicplayTime.Text = "00:00";
                                btnTotalMusicTime.Text = "00:00";
                            }
                        } catch {
                        }
                        #endregion
                        //CD 蓝牙 光纤
                        if (currentMusicModel.SourceID == "8" || currentMusicModel.SourceID == "6" || currentMusicModel.SourceID == "9") {
                            title.Text = "UnKown";
                            progressButton.Width = 0;
                            btnMusicplayTime.Text = "00:00";
                            btnTotalMusicTime.Text = "00:00";
                        }
                    });
                }
            });
        }
    }
}