Inheritance: ISourceChangeRequestedEventArgs
        private async void receiver_SourceChangeRequested(PlayToReceiver recv, SourceChangeRequestedEventArgs args)
        {
            IsPlayReceivedPreMediaLoaded = false;
            if (args.Stream == null)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                {
                    if (currentType == MediaType.AudioVideo && dmrVideo != null)
                    {
                        dmrVideo.Stop();
                    }
                    else if (currentType == MediaType.Image && dmrImage != null)
                    {
                        dmrImage.Source = null;
                        dmrImage.Opacity = 0;
                    }
                    currentType = MediaType.None;
                });
            }
            else if (args.Stream.ContentType.Contains("image"))
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                    {
                        imagerevd = new BitmapImage();
                        imagerevd.ImageOpened += imagerevd_ImageOpened;
                        imagerevd.SetSource(args.Stream);
                        if (currentType != MediaType.Image)
                        {
                            if (currentType == MediaType.AudioVideo)
                            {
                                dmrVideo.Stop();
                            }
                            dmrImage.Opacity = 1;
                            dmrVideo.Opacity = 0;
                        }
                        currentType = MediaType.Image;
                    });
            }
            else
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                {
                    try
                    {
                        justLoadedMedia = true;
                        dmrVideo.SetSource(args.Stream, args.Stream.ContentType);
                    }
                    catch (Exception exp)
                    {
                        rootPage.NotifyUser(exp.Message + " Content Type: " + args.Stream.ContentType, NotifyType.ErrorMessage);
                    }

                    if (currentType == MediaType.Image)
                    {
                        dmrImage.Opacity = 0;
                        dmrVideo.Opacity = 1;
                        dmrImage.Source = null;
                    }
                    currentType = MediaType.AudioVideo;
                });
            }
        }
Exemplo n.º 2
0
 private async void receiver_SourceChangeRequested(PlayToReceiver sender, SourceChangeRequestedEventArgs args)
 {
     if (args.Stream != null)
     {
         await this.dispatcher.RunAsync(
             CoreDispatcherPriority.Normal,
             () =>
             {
                 var stream = args.Stream as IRandomAccessStream;
                 this.VideoPlayer.SetSource(stream, args.Stream.ContentType);
             });
     }
 }
Exemplo n.º 3
0
 async void receiver_SourceChangeRequested(PlayToReceiver sender, SourceChangeRequestedEventArgs args)
 {
     if (args.Stream != null)
     {
         if (args.Stream.ContentType.Contains("image"))
         {
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
             {
                 BitmapImage bmp = new BitmapImage();
                 bmp.SetSource(args.Stream);
                 PhotoSource.Source = bmp;
                 ShowSelectedPanel(1);
             });
         }
         else if (args.Stream.ContentType.Contains("video"))
         {
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
             {
                 VideoSource.SetSource(args.Stream, args.Stream.ContentType);
                 ShowSelectedPanel(3);
             });
         }
         else if (args.Stream.ContentType.Contains("audio"))
         {
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
             {
                 MusicSource.SetSource(args.Stream, args.Stream.ContentType);
                 ShowSelectedPanel(2);
                 MusicSource.Play();
             });
         }
     }
 }