예제 #1
0
        private void Page_OnLoaded(object sender, RoutedEventArgs e)
        {
            var mediaPlayer = new MediaPlayer();

            // We use a helper class that logs all the events for the MediaPlayer:
            mediaPlayerLogger = new MediaPlayerLogger(LoggerControl, mediaPlayer);

            // In addition to logging, we use the callbacks to update some UI elements in this scenario:
            RegisterForDiscreteControls(mediaPlayer);
            RegisterForPositionUpdateControls(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);

            ContentSelectorControl.Initialize(
                mediaPlayer,
                MainPage.ContentManagementSystemStub.Where(m => !m.Aes && m.Live),
                null,
                LoggerControl,
                LoadSourceFromUriAsync);

            // Initialize scenario specific layout:
            ContentSelectorControl.SetAutoPlay(true);
            mediaPlayerElement.AreTransportControlsEnabled = false;
            LoggerControl.Height = 200;
        }
        private void Page_OnLoaded(object sender, RoutedEventArgs e)
        {
            // Explicitly create the instance of MediaPlayer if you need to register for its events
            // (like MediaOpened / MediaFailed) prior to setting an IMediaPlaybackSource.
            var mediaPlayer = new MediaPlayer();

            // We use a helper class that logs all the events for the MediaPlayer:
            mediaPlayerLogger = new MediaPlayerLogger(LoggerControl, 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);

            // This Scenario focuses on event handling, mostly via the "Logger" helper classes
            // in the Shared folder.
            //
            // In addition, the App can also insert an IHttpFilter into the Windows.Web.Http stack
            // which is used by the AdaptiveMediaSource.  To do so, it must derive a class from
            // IHttpFilter, provide the HttpBaseProtocolFilter to that class to execute requests,
            // then use the derived filter as the constructor for the HttpClient.
            //
            // The HttpClient is then used in the constructor of the AdaptiveMediaSource.
            // The App should explicitly set:
            //   CacheControl.WriteBehavior = HttpCacheWriteBehavior.NoCache
            // When passing an HttpClient into the constructor of AdpativeMediaSource,
            // set this on the HttpBaseProtocolFilter.
            //
            // More than one IHttpFilter can be nested, for example, an App might
            // use a filter to modify web requests: see Scenario3 for details.
            //
            // In this scenario, we add an AdaptiveMediaSourceHttpFilterLogger to provide additional
            // verbose logging details for each request.
            var baseProtocolFilter = new HttpBaseProtocolFilter();

            baseProtocolFilter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.NoCache;  // Always set WriteBehavior = NoCache
            var fistLevelFilter = new AdaptiveMediaSourceHttpFilterLogger(LoggerControl, baseProtocolFilter);
            var httpClient      = new HttpClient(fistLevelFilter);


            ContentSelectorControl.Initialize(
                mediaPlayer,
                MainPage.ContentManagementSystemStub.Where(m => !m.Aes),
                httpClient,
                LoggerControl,
                LoadSourceFromUriAsync);
        }
        private void Page_OnLoaded(object sender, RoutedEventArgs e)
        {
            var mediaPlayer = new MediaPlayer();

            // We use a helper class that logs all the events for the MediaPlayer:
            mediaPlayerLogger = new MediaPlayerLogger(LoggerControl, 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);

            ContentSelectorControl.Initialize(
                mediaPlayer,
                MainPage.ContentManagementSystemStub.Where(m => !m.Aes),
                null,
                LoggerControl,
                LoadSourceFromUriAsync);
        }
        private void Page_OnLoaded(object sender, RoutedEventArgs e)
        {
            // We enforce HDCP in this scenario that uses encryption but not PlayReady.
            hdcpSession = new HdcpSession();

            // The protection level may change if screens are plugged or unplugged from the system or
            // if explicitly set in the radio buttons in the UI.
            hdcpSession.ProtectionChanged += (HdcpSession session, object args) =>
            {
                // After a change, impose a maximum bitrate based on the actual protection level.
                HdcpProtection?protection = session.GetEffectiveProtection();
                SetMaxBitrateForProtectionLevel(protection, adaptiveMediaSource);
            };

            // Explicitly create the instance of MediaPlayer if you need to register for its events
            // (like MediaOpened / MediaFailed) prior to setting an IMediaPlaybackSource.
            var mediaPlayer = new MediaPlayer();

            // We use a helper class that logs all the events for the MediaPlayer:
            mediaPlayerLogger = new MediaPlayerLogger(LoggerControl, mediaPlayer);

            mediaPlayerElement.SetMediaPlayer(mediaPlayer);

            ContentSelectorControl.Initialize(
                mediaPlayer,
                MainPage.ContentManagementSystemStub.Where(m => !m.PlayReady),
                null,
                LoggerControl,
                LoadSourceFromUriAsync);

            ContentSelectorControl.HideLoadUri(); // Avoid free text URIs for this scenario.

            // Initialize tokenMethod based on the default selected radio button.
            var defaultRadioButton = AzureAuthorizationMethodPanel.Children.OfType <RadioButton>().First(button => button.IsChecked.Value);

            Enum.TryParse((string)defaultRadioButton.Tag, out tokenMethod);

            Log("Content Id 13 and 14 require that you choose an authorization method.");
            ContentSelectorControl.SetSelectedModel(MainPage.ContentManagementSystemStub.Where(m => m.Id == 13).FirstOrDefault());
        }
예제 #5
0
        private void Page_OnLoaded(object sender, RoutedEventArgs e)
        {
            var mediaPlayer = new MediaPlayer();

            // We use a helper class that logs all the events for the MediaPlayer:
            mediaPlayerLogger = new MediaPlayerLogger(LoggerControl, 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);

            ContentSelectorControl.Initialize(
                mediaPlayer,
                MainPage.ContentManagementSystemStub.Where(m => !m.Aes),
                null,
                LoggerControl,
                LoadSourceFromUriAsync);

            // There is no InboundBitsPerSecondChanged event, so we start a polling thread to update UI.
            PollForInboundBitsPerSecond(ctsForInboundBitsPerSecondUiRefresh);
        }