public IAsyncOperationWithProgress <HttpResponseMessage, HttpProgress> SendRequestAsync(HttpRequestMessage request) { timeToResponseComplete.Start(); logView.Log($"{{\"FILTER SendRequestAsync\":{{\"requestUri\":\"{request.RequestUri}\"}}}}", LogViewLoggingLevel.Verbose); return(AsyncInfo.Run <HttpResponseMessage, HttpProgress>(async(cancellationToken, operationProgressReporter) => { IAsyncOperationWithProgress <HttpResponseMessage, HttpProgress> innerOperation = innerFilter.SendRequestAsync(request); innerOperation.Progress += new AsyncOperationProgressHandler <HttpResponseMessage, HttpProgress>( (IAsyncOperationWithProgress <HttpResponseMessage, HttpProgress> asyncInfo, HttpProgress httpProgressInfo) => { logView.Log($"{{\"FILTER Progress Handler\": {{\"requestUri\":\"{request.RequestUri}\", {httpProgressInfo.ToJsonObject()}}}}}", LogViewLoggingLevel.Verbose); }); HttpResponseMessage response = await innerOperation.AsTask(cancellationToken, operationProgressReporter); cancellationToken.ThrowIfCancellationRequested(); // At this point, SendRequest has completed and we have a response. timeToResponseComplete.Stop(); // We could inspect the content of the response headers: var countHeaders = response.Headers.Count(); logView.Log($"{{\"FILTER Response Complete\": {{\"StatusCode\":\"{response.StatusCode}\",\"timeToResponseComplete\":\"{timeToResponseComplete.ElapsedMilliseconds}\",\"requestUri\":\"{request.RequestUri}\",\"countHeaders\":\"{countHeaders}\"}}}}", LogViewLoggingLevel.Verbose); if (!response.IsSuccessStatusCode) { logView.Log($"{{\"FILTER Response Failed\": {{\"StatusCode\":\"{response.StatusCode}\",\"timeToResponseComplete\":\"{timeToResponseComplete.ElapsedMilliseconds}\",\"requestUri\":\"{request.RequestUri}\",\"countHeaders\":\"{countHeaders}\"}}}}", LogViewLoggingLevel.Error); } // Note that we should NOT attempt to access the response.Content in an IHttpFilter such as this, // the Content stream is for the base filter and AdaptiveMediaSource to use. // // If you want to download content in the App and then pass it to the AdaptiveMediaSource, // see AppDownloadedKeyRequest in Scenario3, which uses Deferral objects to manage thread timing // with the AdaptiveMediaSource. return response; })); }
private void AudioTracks_SelectedIndexChanged(ISingleSelectMediaTrackList sender, object args) { MediaPlaybackAudioTrackList list = sender as MediaPlaybackAudioTrackList; AudioTrack audioTrack = list[sender.SelectedIndex]; MediaPlaybackItem mpItem = audioTrack.PlaybackItem; object customValue; mpItem.Source.CustomProperties.TryGetValue("contentId", out customValue); string contentId = (string)customValue; string audioCodec = audioTrack.GetEncodingProperties().Subtype; var msg = $"The newly selected audio track of {contentId} has Codec {audioCodec}"; var language = audioTrack.Language; if (!String.IsNullOrEmpty(language)) { // Transform the language code into a UI-localized language name. msg += ", Language: " + (new Language(language)).DisplayName; } logView.Log(msg, LogViewLoggingLevel.Information); }
private void Source_StateChanged(MediaSource sender, MediaSourceStateChangedEventArgs args) { logView.Log($"Source.StateChanged:{args.OldState} to {args.NewState}", LogViewLoggingLevel.Information); }
private void CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args) { logView.Log($"{args.ToJsonObject()}", LogViewLoggingLevel.Information); }
private void MediaPlayer_SourceChanged(MediaPlayer sender, object args) { logView.Log("MediaPlayer_SourceChanged", LogViewLoggingLevel.Information); }
private void DiagnosticAvailable(AdaptiveMediaSourceDiagnostics sender, AdaptiveMediaSourceDiagnosticAvailableEventArgs args) { logView.Log($"{args.ToJsonObject()}", LogViewLoggingLevel.Warning); }