Пример #1
0
        private async void GetStreamButton_Click(object sender, EventArgs e)
        {
            Track track = (Track)TrackListBox.SelectedItem;

            if (track != null)
            {
                StreamResponse response = await _client.StreamAsync(track.Id, sessionId);

                OutputTextBox.Text = response.Error == null ? response.Url : response.Error.Description;
            }
        }
Пример #2
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;
            }
        }