/// <summary> /// 连续点击视频时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MediaContainer_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) { if (isTapped) { PlayPauseButton.Focus(FocusState.Programmatic); isTapped = false; SwitchStatus(); } else { MediaContainer_Tapped(Media, new TappedRoutedEventArgs()); } }
private void OnBorderVisibilityChanged(DependencyObject sender, DependencyProperty dp) { if (dp == Border.VisibilityProperty) { // Since the container is not visible, we can't focus the PlayPauseButton before the fadein // animation actually starts. Using opacity only to "hide" the border is not an option, since // doing so would keep the button focused while invisible, and pressing A would pause instead of // showing the control panel. // As a work around, we wait for the container to be visible again. if (((Border)sender).Visibility == Visibility.Visible) { PlayPauseButton.Focus(FocusState.Programmatic); } } }
/// <summary> /// 点击视频画面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MediaContainer_Tapped(object sender, TappedRoutedEventArgs e) { PlayPauseButton.Focus(FocusState.Programmatic); var timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(200); timer.Tick += ((s, ea) => { if (isTapped) { isTapped = false; IsShowControlPanel = !IsShowControlPanel; } timer.Stop(); }); isTapped = true; timer.Start(); }
private void Media_CurrentStateChanged(object sender, RoutedEventArgs e) { var i = Media.CurrentState; switch (i) { case MediaElementState.Playing: { PlayPauseButton.Focus(FocusState.Programmatic); StatusText.Visibility = Visibility.Collapsed; Status.Visibility = Visibility.Collapsed; PlayPauseSymbol.Symbol = Symbol.Pause; SettingHelper.IsScreenAlwaysOn = true; DanmakuManager.Resume(); break; } case MediaElementState.Paused: { goto case MediaElementState.Closed; } case MediaElementState.Stopped: { goto case MediaElementState.Closed; } case MediaElementState.Closed: { //修改按钮图标 PlayPauseSymbol.Symbol = Symbol.Play; //取消屏幕常亮 SettingHelper.IsScreenAlwaysOn = false; DanmakuManager.Pause(); break; } } }
/// <summary> /// 点击控制栏获取焦点以便进行键盘控制 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ControlPanel_Tapped(object sender, TappedRoutedEventArgs e) { PlayPauseButton.Focus(FocusState.Programmatic); }