public void onKeyDown(object sender, KeyEventArgs e) { switch (e.Key) { case Key.LeftCtrl: if (this.Video.RelatedVideo != null) { var time = this.Video.Control.Time; if (this.Video.RelatedVideo.CanSeekOffset) { time = time + (this.Video.RelatedVideo.SeekOffset * 1000); } if (time < 0) { time = 0; } else if (time > this.video.RelatedVideo.Duration) { time = this.video.RelatedVideo.Duration; } //this.Video.RelatedVideo.Play(); this.Video.RelatedVideo.Control.Time = time; this.Video.RelatedVideo.Control.Refresh(); } //e.Handled = true; break; case Key.Space: if (this.Video.Status == MEDIA_STATUS.PLAYING) { pause(sender, e); } else { play(sender, e); } e.Handled = true; break; case Key.Right: var tr = new Thread(new ThreadStart(delegate { if (Video.Status == MEDIA_STATUS.PAUSED /*(e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control*/) { nextFrame(sender, e); } else { fastForward(sender, e); Thread.Sleep(250); } })); tr.Start(); e.Handled = true; break; case Key.Left: var tl = new Thread(new ThreadStart(delegate { if (Video.Status == MEDIA_STATUS.PAUSED /*(e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control*/) { prevFrame(sender, e); } else { rewind(sender, e); Thread.Sleep(250); } })); tl.Start(); e.Handled = true; break; case Key.F1: Snapshot s1 = this.Video.Snapshot(1); if (s1 != null) { SnapshotTaken.Invoke(sender, e, s1); } else { MessageBox.Show("Error al capturar la imagen. Inténtelo nuevamente.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } e.Handled = true; break; case Key.F2: Snapshot s2 = this.Video.Snapshot(2); if (s2 != null) { SnapshotTaken.Invoke(sender, e, s2); } else { MessageBox.Show("Error al capturar la imagen. Inténtelo nuevamente.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } e.Handled = true; break; case Key.F3: Snapshot s3 = this.Video.Snapshot(3); if (s3 != null) { SnapshotTaken.Invoke(sender, e, s3); } else { MessageBox.Show("Error al capturar la imagen. Inténtelo nuevamente.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } e.Handled = true; break; case Key.F4: Snapshot s4 = this.Video.Snapshot(4); if (s4 != null) { SnapshotTaken.Invoke(sender, e, s4); } else { MessageBox.Show("Error al capturar la imagen. Inténtelo nuevamente.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } e.Handled = true; break; case Key.F5: Snapshot s5 = this.Video.Snapshot(5); if (s5 != null) { SnapshotTaken.Invoke(sender, e, s5); } else { MessageBox.Show("Error al capturar la imagen. Inténtelo nuevamente.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } e.Handled = true; break; case Key.Add: Video.Speed = Video.Speed + 1; e.Handled = true; //syncVideos(); break; case Key.Subtract: Video.Speed = Video.Speed - 1; //e.Handled = true; //syncVideos(); break; default: if (!this.seekOffset.IsFocused) { var pressedNumber = 0; if (e.Key == Key.D1 || e.Key == Key.NumPad1) { pressedNumber = 1; } else if (e.Key == Key.D2 || e.Key == Key.NumPad2) { pressedNumber = 2; } else if (e.Key == Key.D3 || e.Key == Key.NumPad3) { pressedNumber = 3; } else if (e.Key == Key.D4 || e.Key == Key.NumPad4) { pressedNumber = 4; } else if (e.Key == Key.D5 || e.Key == Key.NumPad5) { pressedNumber = 5; } else if (e.Key == Key.D6 || e.Key == Key.NumPad6) { pressedNumber = 6; } else if (e.Key == Key.D7 || e.Key == Key.NumPad7) { pressedNumber = 7; } else if (e.Key == Key.D8 || e.Key == Key.NumPad8) { pressedNumber = 8; } else if (e.Key == Key.D9 || e.Key == Key.NumPad9) { pressedNumber = 9; } if (pressedNumber > 0) { Video.Speed = (uint)pressedNumber; //syncVideos(); } } break; } }
public void OnMediaPlayerSnapshotTaken(string fileName) { SnapshotTaken?.Invoke(this, new VlcMediaPlayerSnapshotTakenEventArgs(fileName)); }