public async Task SearchTracks(string query) {
            var currLoadId = ++loadId;

            BeginSearch();

            Track[] results;
            try {
                var path = "http://www.eqbeats.org/tracks/search/json?q=" + Uri.EscapeUriString(query);
                var request = WebRequest.CreateHttp(path);
                request.Accept = "application/json";
                using (var response = await request.GetResponseAsync())
                using (var responseStream = response.GetResponseStream())
                using (var reader = new StreamReader(responseStream)) {
                    results = await JsonConvert.DeserializeObjectAsync<Track[]>(await reader.ReadToEndAsync());
                }
            } catch {
                results = new Track[0];
            }

            if (currLoadId != loadId) {
                return;
            }

            UpdateResults(results);
        }
Beispiel #2
0
        public void SetTrack(Track track)
        {
            MediaPlayer.Source = track.Download.Mp3;
            MediaPlayer.Play();

            UpdateScreenInfo(track);
        }
Beispiel #3
0
        public void UpdateScreenInfo(Track track)
        {
            TopPane.DataContext = track;

            var art = track.Download.Art;

            if (art != null) {
                AlbumArt.Source = new BitmapImage(art);
                AlbumArt.Visibility = Visibility.Visible;
            } else {
                AlbumArt.Visibility = Visibility.Collapsed;
            }

            MediaControl.ArtistName = track.Artist.Name;
            MediaControl.TrackName = NonAsciiRegex.Replace(track.Title, "");
        }