示例#1
0
        public static TopTenCollection CreateNewObject()
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://eradio.ua/top_ten.php");
                var            data    = Encoding.ASCII.GetBytes("src=http://eradio.ua/rock/");
                request.Method      = "POST";
                request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
                request.Headers.Add("Accept-Encoding", "gzip, deflate");
                request.ContentLength = data.Length;
                var stream = request.GetRequestStream();
                stream.Write(data, 0, data.Length);
                stream.Close();
                HttpWebResponse response         = (HttpWebResponse)request.GetResponse();
                Stream          streamResponse   = response.GetResponseStream();
                GZipStream      streamDecompress = new GZipStream(streamResponse, CompressionMode.Decompress);
                StreamReader    sr = new StreamReader(streamDecompress);
                string          s  = sr.ReadToEnd();
                sr.Close();

                string sPicture = "<img src=\"[^\"]*\"";
                string sArtist  = "</audio>[^-]*";
                string sTrack   = "- <span>[^<]*";
                string sSrcFile = "\" src=\"..[^\"]*";

                MatchCollection pictures = Regex.Matches(s, sPicture);
                MatchCollection artists  = Regex.Matches(s, sArtist);
                MatchCollection tracks   = Regex.Matches(s, sTrack);
                MatchCollection srcFiles = Regex.Matches(s, sSrcFile);

                TopTenCollection historyPlayObj = new TopTenCollection();
                for (int i = 0; i < artists.Count; i++)
                {
                    historyPlayObj._lstTopTen.Add(new TopTenItem
                    {
                        ImagePath   = pictures[i].Value.Remove(0, 10).Trim('"'),
                        ArtistName  = artists[i].Value.Remove(0, 9).Trim(' '),
                        TrackName   = tracks[i].Value.Remove(0, 8),
                        SrcFilePath = "http://eradio.ua" + srcFiles[i].Value.Remove(0, 9),
                        ImageBitmap = WebProvider.GetImageBitmapFromUrl(pictures[i].Value.Remove(0, 10).Trim('"'))
                    });
                }
                return(historyPlayObj);
            }
            catch { return(null); }
        }
示例#2
0
文件: ActMain.cs 项目: shyshka/Eradio
 private void OnNowPlayChanged(object obj, NowPlay arg)
 {
     RunOnUiThread(() => {
         tViewArtist.Text             = arg.ARTIST_NAME;
         tViewTrack.Text              = arg.TRACK_SONG;
         Android.Graphics.Bitmap logo = WebProvider.GetImageBitmapFromUrl(arg.PICTURE);
         if (logo != null)
         {
             iViewTrack.SetImageBitmap(logo);
         }
         else
         {
             iViewTrack.SetImageResource(Resource.Drawable.Erock);
         }
         //Animation anim = AnimationUtils.LoadAnimation (this, Resource.Layout.AnimCombo);
         //iViewTrack.StartAnimation (anim);
     });
 }