public async Task GetPlaylistsAsync() { ContentResponse playlists = await _grooveClient.BrowseAsync( MediaNamespace.music, ContentSource.Collection, ItemType.Playlists); await _errorViewModel.HandleGrooveApiErrorAsync(playlists.Error); DisplayMusicContent(playlists); }
/// <summary> /// Gets the Groove profile of the currently logged-in user and updates the <see cref="UserHasGrooveSubscription"/> /// and <see cref="UserGrooveSubscriptionCountry"/> properties. /// </summary> private async Task UpdateUserSubscriptionInformationAsync() { UserProfileResponse profileResponse = await _grooveClient.GetUserProfileAsync(MediaNamespace.music); await _errorViewModel.HandleGrooveApiErrorAsync(profileResponse.Error); UserHasGrooveSubscription = profileResponse.HasSubscription ?? false; UserGrooveSubscriptionCountry = profileResponse.Subscription?.Region; }
public async Task PlayTrackAsync(Track track, bool userIsSignedIn, bool userHasSubscription) { bool trackCanBeStreamed = track.Rights != null && track.Rights.Any(right => right.Equals(StreamRight, StringComparison.OrdinalIgnoreCase)); StreamResponse streamResponse = trackCanBeStreamed && userIsSignedIn && userHasSubscription ? await _grooveClient.StreamAsync(track.Id, StreamClientInstanceId.GetStableClientInstanceId()) : await _grooveClient.PreviewAsync(track.Id, StreamClientInstanceId.GetStableClientInstanceId()); await _errorViewModel.HandleGrooveApiErrorAsync(streamResponse.Error); if (!string.IsNullOrEmpty(streamResponse.Url)) { MediaSource = await GetMediaSource(new Uri(streamResponse.Url), streamResponse.ContentType); } }