private static void OnIsVideoStartedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { MediaElementExt mediaElementExt = (MediaElementExt)d; if (mediaElementExt != null) { bool?newValue = (bool?)(e.NewValue as bool?); if ((!newValue.GetValueOrDefault() ? false : newValue.HasValue)) { MediaElementExt.SwitchStateToNonloading(mediaElementExt); return; } if (mediaElementExt.NotificationContent == null) { MediaElementExt.SwitchStateToLoading(mediaElementExt); } } }
public MediaElementExt() { this.timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(5) }; this.timer.Tick += new EventHandler(this.timer_Tick); this.loadingTimer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(30) }; this.loadingTimer.Tick += new EventHandler(this.loadingTimer_Tick); this.ccDataDecoder = new CCDataDecoder(); this.ccDataDecoder.ShowCaption += new EventHandler <CaptionEventArgs>(this.ccDataDecoder_ShowCaption); this.ccDataDecoder.HideCaption += new EventHandler <CaptionEventArgs>(this.ccDataDecoder_HideCaption); Grid grid = new Grid(); MediaElementExt.SwitchStateToLoading(this); base.Unloaded += new RoutedEventHandler(this.MediaElementExt_Unloaded); }
private static void OnNotificationTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { MediaElementExt mediaElementExt = (MediaElementExt)d; mediaElementExt.OnContentChanged(e.OldValue, e.NewValue); if (e.NewValue == null) { MediaElementExt.SwitchStateToLoading(mediaElementExt); VisualStateManager.GoToState(mediaElementExt, "STATE_NotificationNonVisible", true); mediaElementExt.NotificationContent = null; return; } try { MessageType messageType = (MessageType)Enum.Parse(typeof(MessageType), e.NewValue.ToString()); if (messageType != MessageType.AudioVideo && messageType != MessageType.HdmiConflict && messageType != MessageType.NeedRestart) { VisualStateManager.GoToState(mediaElementExt, "STATE_NotificationVisible", true); StackPanel stackPanel = new StackPanel(); TextBlock textBlock = new TextBlock(); Image image = new Image(); if (messageType != MessageType.AudioOnly && messageType != MessageType.HdmiConflict && messageType != MessageType.NeedRestart) { textBlock.FontSize = 26; textBlock.Foreground = new SolidColorBrush(Colors.White); textBlock.FontWeight = FontWeights.Bold; textBlock.TextWrapping = TextWrapping.WrapWithOverflow; textBlock.TextAlignment = TextAlignment.Center; stackPanel.Children.Add(textBlock); if (messageType == MessageType.HdmiConflict) { textBlock.Text = ResourcesModel.Instanse.MAPP_SID_TV_CURRENT_STATUS_PREVENTS_SCREEN_SHARING_WINDOW; } else if (messageType == MessageType.AndroidPriority) { textBlock.Text = ResourcesModel.Instanse.MAPP_SID_TV_NO_LONGER_AVAILABLE_ANDROID_DEVICE; } else if (messageType == MessageType.LowPriority) { textBlock.Text = ResourcesModel.Instanse.MAPP_SID_YOU_CAN_NOT_WATCH_2ND_TV_ANYMORE; } else if (messageType == MessageType.SourceConflict || messageType == MessageType.OtherMode) { textBlock.Text = ResourcesModel.Instanse.MAPP_SID_CANNOT_WATCH_TV_MOBILE_DEVICE_CURRENT_TV_MODE; } else if (messageType == MessageType.NoSignal) { textBlock.Text = ResourcesModel.Instanse.COM_SID_NO_SIGNAL; } else if (messageType == MessageType.CheckCable) { textBlock.Text = ResourcesModel.Instanse.MAPP_SID_CHECK_CABLE; } else if (messageType == MessageType.DataService) { textBlock.Text = ResourcesModel.Instanse.COM_TV_SID_DATA_SERVICE_CHANNEL; } else if (messageType == MessageType.Locked) { textBlock.Text = ResourcesModel.Instanse.COM_SID_THIS_CHANNEL_LOCKED_MSG; } else if (messageType == MessageType.NotAvailable) { textBlock.Text = ResourcesModel.Instanse.COM_SID_NOT_AVAILABLE; } else if (messageType == MessageType.NotAvailable3D) { textBlock.Text = ResourcesModel.Instanse.COM_TV_SID_3D_IS_NOT_SUPPORTED; } else if (messageType == MessageType.NotConnected) { textBlock.Text = ResourcesModel.Instanse.MAPP_SID_NOT_CONNECTED; } else if (messageType == MessageType.ParentalLock) { textBlock.Text = ResourcesModel.Instanse.MAPP_SID_PARENTAL_LOCK; } else if (messageType == MessageType.ScrambledChannel) { textBlock.Text = ResourcesModel.Instanse.MAPP_SID_SCRAMLED_CHANNEL; } else if (messageType == MessageType.ServiceNotAvailable) { textBlock.Text = ResourcesModel.Instanse.COM_TV_SID_THIS_SERVICE_IS_NOT_AVAILABLE; } else if (messageType == MessageType.Recording) { textBlock.Text = ResourcesModel.Instanse.MAPP_SID_NOT_AVAILABLE_TV_RECORIDNG; } else if (messageType != MessageType.NeedRestart) { textBlock.Text = "Some error.:'("; } else { textBlock.Text = ResourcesModel.Instanse.COM_TV_SID_CLOSING_MULTI_DISPLAY_TV_MSG_KR_NETWORK; Button button = new Button() { Content = ResourcesModel.Instanse.COM_TV_SID_TRY_AGAIN, Margin = new Thickness(10), HorizontalAlignment = System.Windows.HorizontalAlignment.Center, Style = (System.Windows.Style)Application.Current.Resources["TheMostCommonButtonStyle"], FontSize = 26, Padding = new Thickness(2) }; stackPanel.Children.Add(button); Binding binding = new Binding("RestartCommand") { Mode = BindingMode.OneWay, Source = mediaElementExt.DataContext }; button.SetBinding(ButtonBase.CommandProperty, binding); } } else { BitmapImage bitmapImage = new BitmapImage(); stackPanel.Children.Add(image); bitmapImage.BeginInit(); bitmapImage.UriSource = new Uri("pack://application:,,,/Resources/Images/2nd_exception_icon.png"); bitmapImage.EndInit(); image.Stretch = Stretch.None; image.Source = bitmapImage; } mediaElementExt.NotificationContent = stackPanel; MediaElementExt.SwitchStateToNonloading(mediaElementExt); } else { VisualStateManager.GoToState(mediaElementExt, "STATE_NotificationNonVisible", true); } } catch { MediaElementExt.SwitchStateToLoading(mediaElementExt); } }