private void ShowTransportGrid() { InlineFrame.IsEnabled = false; if (InlineFrame.Content is IXboxInputPage) { ((IXboxInputPage)InlineFrame.Content).PreserveFocus(); } //TransportControlGrid.Visibility = Visibility.Visible; transportGridAnimating = true; Storyboard storyboard = ((Storyboard)TransportControlGrid.Resources["EnterStoryboard"]); EventHandler <object> handler = null; handler = new EventHandler <object>((x, y) => { storyboard.Completed -= handler; transportGridAnimating = false; transportGridVisible = true; TransportControlGrid.IsHitTestVisible = true; PlayButton.Focus(FocusState.Keyboard); ElementSoundPlayer.Play(ElementSoundKind.Show); }); storyboard.Completed += handler; storyboard.Begin(); }
protected override void OnAppearing() { base.OnAppearing(); _isPageDisappeared = false; MessagingCenter.Subscribe <IKeyEventSender, string>(this, "KeyDown", (s, e) => { KeyEventHandler(e); }); PlayButton.Focus(); Device.StartTimer(UpdateInterval, UpdatePlayerControl); }
public void Show(int timeout) { // Do not show anything if error handling in progress. if (_hasFinished) { return; } if (!_isShowing) { PlayButton.Focus(); _isShowing = true; } TopBar.IsVisible = true; BottomBar.IsVisible = true; _hideTime = timeout; }
//Move focus where needed, a crude way of doing it thou //int indicates direction private void MoveFocus(int e) { //0 = down if (e == 0) { if (PlayButton.IsFocused) { OptionsButton.Focus(); } else if (OptionsButton.IsFocused) { ExitButton.Focus(); } else if (ExitButton.IsFocused) { PlayButton.Focus(); } else { PlayButton.Focus(); } } //1 = up if (e == 1) { if (PlayButton.IsFocused) { ExitButton.Focus(); } else if (OptionsButton.IsFocused) { PlayButton.Focus(); } else if (ExitButton.IsFocused) { OptionsButton.Focus(); } else { PlayButton.Focus(); } } }
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) { if (VideoPlayer.IsFullWindow) { e.Cancel = true; VideoPlayer.IsFullWindow = false; VideoPlayer.AreTransportControlsEnabled = false; PlayButton.Focus(FocusState.Keyboard); return; } if (VideoPlayer.Source != null) { VideoPlayer.Source = null; VideoPlayer.MediaPlayer.CurrentStateChanged -= MediaPlayer_CurrentStateChanged; } base.OnNavigatingFrom(e); }
private void OnPlayerStateChanged(PlayerState state) { Logger.Info($"Player State Changed: {state}"); if (_isPageDisappeared) { Logger.Warn("Page scheduled for disappearing or already disappeared. Stale Event? Not Processed."); return; } switch (state) { case PlayerState.Prepared: { if (_playerService.IsSeekingSupported) { BackButton.IsEnabled = true; ForwardButton.IsEnabled = true; } PlayButton.IsEnabled = true; SettingsButton.IsEnabled = true; PlayButton.Focus(); _playerService.Start(); Show(); break; } case PlayerState.Playing: PlayImage.Source = ImageSource.FromFile("btn_viewer_control_pause_normal.png"); break; case PlayerState.Paused: PlayImage.Source = ImageSource.FromFile("btn_viewer_control_play_normal.png"); break; } }
private void setFocusToPlayButton(object sender, RoutedEventArgs e) { PlayButton.Focus(FocusState.Programmatic); }
private void KeyEventHandler(string e) { // Prevents key handling & focus change in Show(). // Consider adding a call Focus(Focusable Object) where focus would be set in one place // and error status could be handled. if (_hasFinished) { return; } if (e.Contains("Back") && !e.Contains("XF86PlayBack")) { //If the 'return' button on standard or back arrow on the smart remote control was pressed do react depending on the playback state if (_playerService.State < PlayerState.Playing || _playerService.State >= PlayerState.Playing && !_isShowing) { //return to the main menu showing all the video contents list Navigation.RemovePage(this); } else { if (Settings.IsVisible) { Settings.IsVisible = false; PlayButton.IsEnabled = true; PlayButton.Focus(); } else { Hide(); } } } else { if (Settings.IsVisible) { return; } if (_isShowing) { if ((e.Contains("Play") || e.Contains("XF86PlayBack")) && _playerService.State == PlayerState.Paused) { _playerService.Start(); } else if ((e.Contains("Pause") || e.Contains("XF86PlayBack")) && _playerService.State == PlayerState.Playing) { _playerService.Pause(); } if ((e.Contains("Next") || e.Contains("Right"))) { Forward(); } else if ((e.Contains("Rewind") || e.Contains("Left"))) { Rewind(); } else if ((e.Contains("Up"))) { HandleSettings(); } //expand the time that playback control bar is on the screen _hideTime = DefaultTimeout; } else { if (e.Contains("Stop")) { Navigation.RemovePage(this); } else { //Make the playback control bar visible on the screen Show(); } } } }
public void Resume() { Player?.Resume(); PlayButton.Focus(); }