private static async void SwitchStateToNonloading(MediaElementExt mediaElementExt) { mediaElementExt.fadeOutAnimationEnded = false; VisualStateManager.GoToState(mediaElementExt, "STATE_NonLoading", false); mediaElementExt.loadingTimer.Stop(); await Task.Delay(20); mediaElementExt.fadeOutAnimationEnded = true; }
private static void OnPlayerNotificationProvider(DependencyObject d, DependencyPropertyChangedEventArgs e) { MediaElementExt mediaElementExt = d as MediaElementExt; IPlayerNotificationProvider newValue = e.NewValue as IPlayerNotificationProvider; if (newValue != null && mediaElementExt != null) { newValue.CCDataReceived += new EventHandler <CCDataEventArgs>(mediaElementExt.OnCCDataReceived); } if (e.OldValue != null && mediaElementExt != null) { ((IPlayerNotificationProvider)e.OldValue).CCDataReceived -= new EventHandler <CCDataEventArgs>(mediaElementExt.OnCCDataReceived); } }
private static void OnIsNotificationShownChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { MediaElementExt mediaElementExt = d as MediaElementExt; if (mediaElementExt != null) { bool?newValue = (bool?)(e.NewValue as bool?); if ((!newValue.GetValueOrDefault() ? false : newValue.HasValue)) { VisualStateManager.GoToState(mediaElementExt, "STATE_NotificationVisible", true); return; } VisualStateManager.GoToState(mediaElementExt, "STATE_NotificationNonVisible", true); } }
private static void OnCcDataVisibleChanged(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.ccDataLayout.Visibility = System.Windows.Visibility.Visible; return; } mediaElementExt.ccDataLayout.Visibility = System.Windows.Visibility.Collapsed; } }
private static void OnIsContentFadesChanget(DependencyObject d, DependencyPropertyChangedEventArgs e) { MediaElementExt mediaElementExt = d as MediaElementExt; bool newValue = (bool)e.NewValue; if (mediaElementExt != null && mediaElementExt.layoutRoot != null) { if (!newValue) { mediaElementExt.timer.Stop(); VisualStateManager.GoToState(mediaElementExt, "STATE_Visible", true); return; } mediaElementExt.timer.Start(); } }
private static void MediaElementStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is MediaElementExt) { MediaElementExt mediaElementExt = (MediaElementExt)d; switch ((SmartView2.Controls.MediaElementState)e.NewValue) { case SmartView2.Controls.MediaElementState.Play: { mediaElementExt.mediaElement.Play(); return; } case SmartView2.Controls.MediaElementState.Pause: { if (mediaElementExt.MediaElementState != SmartView2.Controls.MediaElementState.Play) { mediaElementExt.mediaElement.Play(); } mediaElementExt.mediaElement.Pause(); return; } case SmartView2.Controls.MediaElementState.Stop: { mediaElementExt.mediaElement.Pause(); if (!mediaElementExt.mediaElement.NaturalDuration.HasTimeSpan) { break; } mediaElementExt.mediaElement.Position = TimeSpan.FromSeconds(0); return; } case SmartView2.Controls.MediaElementState.Close: { mediaElementExt.mediaElement.Close(); break; } default: { return; } } } }
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); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.mediaElement = ((SmartView2.Controls.MediaElementExt)(target)); return; case 2: #line 23 "..\..\..\..\Views\TvVideoPage.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click); #line default #line hidden return; case 3: #line 36 "..\..\..\..\Views\TvVideoPage.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click); #line default #line hidden return; case 4: this._comboBox = ((System.Windows.Controls.ComboBox)(target)); #line 65 "..\..\..\..\Views\TvVideoPage.xaml" this._comboBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this._comboBox_SelectionChanged); #line default #line hidden return; case 5: this.tvRightControls = ((System.Windows.Controls.Grid)(target)); return; case 6: this.ccDatabutton = ((System.Windows.Controls.Button)(target)); return; case 7: this.stbRightControls = ((System.Windows.Controls.Grid)(target)); return; case 8: this.bdRightControls = ((System.Windows.Controls.Grid)(target)); return; case 9: this.tvBottomControls = ((System.Windows.Controls.Grid)(target)); return; case 10: this.fullScreenButton = ((System.Windows.Controls.Button)(target)); #line 212 "..\..\..\..\Views\TvVideoPage.xaml" this.fullScreenButton.Click += new System.Windows.RoutedEventHandler(this.fullScreenButton_Click); #line default #line hidden return; case 11: this.stbBottomControls = ((System.Windows.Controls.Grid)(target)); return; case 12: #line 255 "..\..\..\..\Views\TvVideoPage.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.fullScreenButton_Click); #line default #line hidden return; case 13: this.bdBottomControls = ((System.Windows.Controls.Grid)(target)); return; case 14: #line 284 "..\..\..\..\Views\TvVideoPage.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.fullScreenButton_Click); #line default #line hidden return; case 15: this.htsBottomControls = ((System.Windows.Controls.Grid)(target)); return; case 16: #line 313 "..\..\..\..\Views\TvVideoPage.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.fullScreenButton_Click); #line default #line hidden return; case 17: this.channelListGrid = ((System.Windows.Controls.Grid)(target)); return; case 18: this.channelList = ((System.Windows.Controls.ListView)(target)); return; } this._contentLoaded = true; }