private async void LoadId_Click(object sender, RoutedEventArgs e)
        {
            adaptiveContentModel = (AdaptiveContentModel)SelectedContent.SelectedItem;

            UriBox.Text = adaptiveContentModel.ManifestUri.ToString();
            await LoadSourceFromUriAsync(adaptiveContentModel.ManifestUri);
        }
        private async void Page_OnLoaded(object sender, RoutedEventArgs e)
        {
            var mediaPlayer = new MediaPlayer();
            RegisterForMediaPlayerEvents(mediaPlayer);

            // Ensure we have PlayReady support, in case the user enters a DASH/PR Uri in the text box.
            var prHelper = new PlayReadyHelper(LoggerControl);
            prHelper.SetUpProtectionManager(mediaPlayer);

            mediaPlayerElement.SetMediaPlayer(mediaPlayer);

            // Choose a default content.
            SelectedContent.ItemsSource = MainPage.ContentManagementSystemStub;
            adaptiveContentModel = MainPage.FindContentById(1);
            SelectedContent.SelectedItem = adaptiveContentModel;

            UriBox.Text = adaptiveContentModel.ManifestUri.ToString();
            await LoadSourceFromUriAsync(adaptiveContentModel.ManifestUri);
        }
        private async void Page_OnLoaded()
        {
            var mediaPlayer = new MediaPlayer();
            RegisterForMediaPlayerEvents(mediaPlayer);

            // Ensure we have PlayReady support, if the user enters a DASH/PR Uri in the text box:
            var prHelper = new PlayReadyHelper(LoggerControl);
            prHelper.SetUpProtectionManager(mediaPlayer);
            mediaPlayerElement.SetMediaPlayer(mediaPlayer);

            // Choose a default content.
            SelectedContent.ItemsSource = MainPage.ContentManagementSystemStub.ToArray();
            adaptiveContentModel = MainPage.FindContentById(10);
            SelectedContent.SelectedItem = adaptiveContentModel;

            UriBox.Text = adaptiveContentModel.ManifestUri.ToString();
            await LoadSourceFromUriAsync(adaptiveContentModel.ManifestUri);

            // There is no InboundBitsPerSecondChanged event, so we start a polling thread to update UI.
            PollForInboundBitsPerSecond(ctsForInboundBitsPerSecondUiRefresh);
        }
        private async void Load_Click(object sender, RoutedEventArgs e)
        {
            adaptiveContentModel = (AdaptiveContentModel)SelectedContent.SelectedItem;

            if (tokenMethod == AzureKeyAcquisitionMethod.AuthorizationHeader)
            {
                // Use an IHttpFilter to identify key request URIs and insert an Authorization header with the Bearer token.
                var baseProtocolFilter = new HttpBaseProtocolFilter();
                httpClientFilter = new AddAuthorizationHeaderFilter(baseProtocolFilter);
                httpClientFilter.AuthorizationHeader = new HttpCredentialsHeaderValue("Bearer", adaptiveContentModel.AesToken);
                var httpClient = new HttpClient(httpClientFilter);

                // Here is where you can add any required custom CDN headers.
                httpClient.DefaultRequestHeaders.Append("X-HeaderKey", "HeaderValue");
                // NOTE: It is not recommended to set Authorization headers needed for key request on the
                // default headers of the HttpClient, as these will also be used on non-HTTPS calls
                // for media segments and manifests -- and thus will be easily visible.

                await LoadSourceFromUriAsync(adaptiveContentModel.ManifestUri, httpClient);
            }
            else
            {
                await LoadSourceFromUriAsync(adaptiveContentModel.ManifestUri);
            }

            // On small screens, hide the description text to make room for the video.
            DescriptionText.Visibility = (ActualHeight < 650) ? Visibility.Collapsed : Visibility.Visible;
        }