wxr
2024-06-07 56da43f1e25a191cd83fb91c5756f19ef7431bb0
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
using System;
using System.Collections.Generic;
using System.Text;
using Shared;
using Shared.SimpleControl.R;
 
namespace Shared.SimpleControl.Pad.Music
{
    class Usbmusic:FrameLayout
    {
        public void show(A31MusicModel a31,List<A31serarchSong> infolist,FrameLayout SettingView,FrameLayout PalyPage)
        {
 
            FrameLayout topFrameLayout = new FrameLayout();
            topFrameLayout.Width = LayoutParams.MatchParent;
            topFrameLayout.Height = Application.GetRealHeight(130);
            topFrameLayout.BackgroundImagePath = "MusicIcon/Backgroun2.png";
            this.AddChidren(topFrameLayout);
 
            Button 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 += Back_MouseDownEventHandler; ;
 
            Button musiclist = new Button
            {
                Width = Application.GetRealWidth(200),
                Height = Application.GetRealHeight(150),
                TextID = MyInternationalizationString.SDcard,
                TextSize = 15,
                X = Application.GetRealWidth(200),
                Gravity = Gravity.CenterVertical,
                //Y = Application.GetRealHeight(10),
            };
            topFrameLayout.AddChidren(musiclist);
 
            VerticalScrolViewLayout middle = new VerticalScrolViewLayout();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight(1136 - 130);
            middle.BackgroundColor = 0xff2F2F2F;
            //middle.BackgroundImagePath = "MusicIcon/HomepageBackgroun.png";
            this.AddChidren(middle);
 
            int number = 0;
 
            foreach(var musicInfo in infolist)
            {
               
              // musicInfo.filename = "http://" + "192.168.1.107"+ ":" + "/httpapi.asp?command=setPlayerCmd:playLocalList/media/sda1/music" + musicInfo.Title;
 
                number++;
                var usbrowL = new RowLayout
                {
                    LineColor = 0x62818181,
                    Height = Application.GetRealHeight(100),
                };
                middle.AddChidren(usbrowL);
 
                var usbtitle = new Button
                {
                    Width = Application.GetRealWidth(80),
                    Height = Application.GetRealHeight(70),
                    X = Application.GetRealWidth(10),
                    Gravity=Gravity.CenterVertical,
                    UnSelectedImagePath="MusicIcon/PlayMusic.png",
                };
                usbrowL.AddChidren(usbtitle);
 
                var usbmusic = new Button
                {
                    Width = LayoutParams.MatchParent,
                    Height = Application.GetRealHeight(100),
                    Text = musicInfo.Title,
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth(120),
                    Tag = number,
                };
                usbrowL.AddChidren(usbmusic);
 
                usbmusic.MouseUpEventHandler += (sender,e) =>{
                    serarchSong(a31.IPAddress, usbmusic.Tag);
                    this.RemoveFromParent();
                                   
                };
 
            }
 
        }
 
 
        /// <summary>
        /// 播放歌曲
        /// </summary>
        /// <param name="Tag"></param>
        /// <returns></returns>
        /// 
        string serarchSong(string id ,object Tag)
        {
            System.Net.WebClient webClient = new System.Net.WebClient();
 
            try
            {
                byte[] recevieBytes = webClient.DownloadData(new Uri("http://"+id +"/httpapi.asp?command=setPlayerCmd:playLocalList"+":"+Tag));
                return System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length);
            }
 
            catch
            {
                return "";
            }
 
        }
 
        private void Back_MouseDownEventHandler(object sender, MouseEventArgs e)
        {
            this.RemoveFromParent();
        }
 
 
    }
}