예제 #1
0
        private async void ShowNotificationLoadingAsync()
        {
            _isNotificationMediaLoaded        = false;
            _isNotificationMediaLoadingFailed = false;

            // Show Notification panel
            _hideDefaultPanel.Begin();
            _showNotificationPanel.Begin();

            // Show the Notification loading animation after delaying 0.5 second
            await Task.Delay(500);

            if (!_isNotificationMediaLoaded && !_isNotificationMediaLoadingFailed)
            {
                _notificationLoadingImageEx.Source = BitmapImageProvider.GetImageFromRemoteSource("ms-appx:///ProximityApp/MediaFiles/Image_Loading.gif");;
            }
        }
예제 #2
0
 public Task AddImage(BitmapImageProvider image)
 {
     throw new NotSupportedException();
 }
예제 #3
0
 private void FailNotificationLoading()
 {
     _isNotificationMediaLoadingFailed = true;
     HideNotificationLoading();
     _notificationLoadingErrorImageEx.Source = BitmapImageProvider.GetImageFromRemoteSource("ms-appx:///ProximityApp/MediaFiles/Image_MediaNotLoaded.png");
 }
예제 #4
0
        // Show the Notification
        private async void ShowNotificationAsync(Notification notificationToShow)
        {
            try
            {
                if (!_isNotificationShowing && !_isUserEventConfirmationShowing)
                {
                    // Validate the Notification content
                    if (notificationToShow != null && notificationToShow.Timeout > 0 && !string.IsNullOrEmpty(notificationToShow.ContentBody))
                    {
                        // Validate the Notification content type
                        if (notificationToShow.ContentMimeType == MimeType.ImagePng ||
                            notificationToShow.ContentMimeType == MimeType.ImageJpeg ||
                            notificationToShow.ContentMimeType == MimeType.ImageJpg ||
                            notificationToShow.ContentMimeType == MimeType.VideoMp4)
                        {
                            _isNotificationShowing = true;      // Set to true

                            // Clean-up Notification's UI control
                            CleanUpNotificationControl();

                            // Assign the NotificationID to the Notification container UI panel
                            _notificationContainerGrid.Tag = notificationToShow.NotificationID;

                            // Reset Notification progress bar
                            _notificationProgressBar.Value      = 0;
                            _notificationProgressBar.Visibility = notificationToShow.ShowProgressBar ? Visibility.Visible : Visibility.Collapsed;
                            _notificationProgressBar.Maximum    = notificationToShow.Timeout; // Current Notification's timeout duration

                            // Start the Notification timeout timer with interval of 1 second
                            _notificationTimeoutTimer.Interval = TimeSpan.FromSeconds(1);
                            _notificationTimeoutTimer.Start();  // Start Notification timeout timer

                            // Start showing Notification in UI
                            ShowNotificationLoadingAsync();

                            // Set Notification's media content based on it's MIME type
                            switch (notificationToShow.ContentMimeType)
                            {
                            case MimeType.ImagePng:
                            case MimeType.ImageJpeg:
                            case MimeType.ImageJpg:
                                // Assign the Notification image content to it's UI image control
                                _notificationImageEx.Source = BitmapImageProvider.GetImageFromRemoteSource(notificationToShow.ContentBody);
                                var log = ">>>Show NotificationID (image content): " + notificationToShow.NotificationID;
                                Log.LogAsync(Log.LoggingLevel.Information, log);
                                Log.DebugLog(log);
                                break;

                            case MimeType.VideoMp4:
                                var videoUri = new Uri(notificationToShow.ContentBody);
                                // Assign the Notification video content to it's UI video control
                                MediaSource videoSource = null;
                                await Task.Run(async() => { videoSource = await VideoCache.Instance.GetFromCacheAsync(videoUri); });

                                if (videoSource != null)
                                {
                                    _notificationVideoPlayer.SetPlaybackSource(videoSource);
                                    log = ">>>Show NotificationID (video content): " + notificationToShow.NotificationID;
                                    Log.LogAsync(Log.LoggingLevel.Information, log);
                                    Log.DebugLog(log);
                                    // Set video player's dimension for the video content
                                    SetVideoPlayerDimensionAsync(videoUri);
                                }
                                else
                                {
                                    NotificationVideoPlayer_MediaFailed(_notificationVideoPlayer, null);
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.LogAsync(Log.LoggingLevel.Error, "Notification content not loaded. EXCEPTION: " + ex.Message);
            }
        }