private async Task <AlphaTab.Model.Score> GetPopularScore() { var scoreService = new ScoreServiceManager(); var list = await scoreService.FetchSongsMostViewed(); var firstSong = list.First(); var songDetails = await scoreService.FetchSongDetailsAsync(firstSong.ID); var score = await scoreService.FetchSongScore(songDetails, true); return(score); }
private async Task LoadTrack() { //`this.LoadingProgress.IsVisible = true; //get first song from favourites _song = await _scoreService.FetchSongDetailsAsync(SelectedSong.ID); //load gp score _score = await _scoreService.FetchSongScore(_song, true); if (_score == null) { await DisplayAlert("Load failed", "Could not load song. Check internet connection", "OK"); return; } var mostPopularTrack = _song.LatestAvailableRevision?.MostPopularTrack?.ID != null?_song.LatestAvailableRevision.Tracks.FirstOrDefault(t => t.ID == _song.LatestAvailableRevision?.MostPopularTrack?.ID) : null; // this.trackPicker.Items.Clear(); Track selectedTrack = null; List <string> tracks = new List <string>(); int trackIndex = 0; foreach (var t in _score.Tracks) { tracks.Add(t.Name); // this.trackPicker.Items.Add(t.Name); trackPicker.Items.Add(t.Name); if (_song.LatestAvailableRevision?.MostPopularTrack?.ID != null) { if (mostPopularTrack != null && t.Name == mostPopularTrack.Title) { selectedTrack = t; _selectedTrackIndex = trackIndex; } } trackIndex++; } if (selectedTrack == null) { selectedTrack = _score.Tracks[0]; } trackPicker.SelectedIndex = _selectedTrackIndex; //SetCurrentTrack(selectedTrack); }