Ejemplo n.º 1
0
        public async Task GetPlaylistsAsync()
        {
            ContentResponse playlists = await _grooveClient.BrowseAsync(
                MediaNamespace.music,
                ContentSource.Collection,
                ItemType.Playlists);

            _errorViewModel.HandleGrooveApiError(playlists.Error);
            DisplayMusicContent(playlists);
        }
Ejemplo n.º 2
0
        /// <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);

            _errorViewModel.HandleGrooveApiError(profileResponse.Error);

            UserHasGrooveSubscription     = profileResponse.HasSubscription ?? false;
            UserGrooveSubscriptionCountry = profileResponse.Subscription?.Region;
        }
Ejemplo n.º 3
0
        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());

            _errorViewModel.HandleGrooveApiError(streamResponse.Error);

            if (!string.IsNullOrEmpty(streamResponse.Url))
            {
                StreamUrl = streamResponse.Url;
            }
        }