private void sourceRequestHandler(
     Windows.Media.PlayTo.PlayToManager sender,
     Windows.Media.PlayTo.PlayToSourceRequestedEventArgs e)
 {
     try
     {
         e.SourceRequest.SetSource(mediaElement.PlayToSource);
     }
     catch (Exception ex)
     {
         messageBlock.Text += "Exception encountered: " + ex.Message + "\n";
     }
 }
        async private void sourceRequestHandlerDeferred(
            Windows.Media.PlayTo.PlayToManager sender,
            Windows.Media.PlayTo.PlayToSourceRequestedEventArgs e)
        {
            var deferral = e.SourceRequest.GetDeferral();

            // Async call to get source media
            var element = await getMediaElementAsync();

            e.SourceRequest.SetSource(element.PlayToSource);

            deferral.Complete();
        }
        private void sourceRequestHandlerWithEvents(
            Windows.Media.PlayTo.PlayToManager sender,
            Windows.Media.PlayTo.PlayToSourceRequestedEventArgs e)
        {
            try
            {
                var controller = mediaElement.PlayToSource;

                controller.Connection.Error        += playToConnectionError;
                controller.Connection.StateChanged += playToConnectionStageChanged;
                controller.Connection.Transferred  += playToConnectionTransferred;

                e.SourceRequest.SetSource(controller);
            }
            catch (Exception ex)
            {
                messageBlock.Text += "Exception encountered: " + ex.Message + "\n";
            }
        }
        private async void SourceRequested(Windows.Media.PlayTo.PlayToManager sender,
                                           Windows.Media.PlayTo.PlayToSourceRequestedEventArgs e)
        {
            var deferral = e.SourceRequest.GetDeferral();

            await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                      () =>
            {
                initialImage = new Image();

                // Use the statechanged event of the image passed to Play To to determine when
                // the image is finally connected to the Play To Receiver.
                initialImage.PlayToSource.Connection.StateChanged += InitialImageConnectionStateChanged;

                // Provide Play To with the first image to stream.
                e.SourceRequest.SetSource(initialImage.PlayToSource);

                deferral.Complete();
            });
        }
 async private void SourceRequested(Windows.Media.PlayTo.PlayToManager sender, Windows.Media.PlayTo.PlayToSourceRequestedEventArgs e)
 {
     var deferral = e.SourceRequest.GetDeferral();
     await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         e.SourceRequest.SetSource(player.PlayToSource);
         deferral.Complete();
     });
 }
Beispiel #6
0
 private async void MainPage_SourceRequested(Windows.Media.PlayTo.PlayToManager sender, Windows.Media.PlayTo.PlayToSourceRequestedEventArgs args)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         try
         {
             Windows.Media.PlayTo.PlayToSourceDeferral deferral = args.SourceRequest.GetDeferral();
             args.SourceRequest.SetSource(AudioController.Default.PlayToSource);
             deferral.Complete();
         }
         catch (Exception) { }
     });
 }