/// <summary> /// キーが押された。各種操作。 /// </summary> private void ExampleMoviePlayer_KeyDown(object sender, KeyEventArgs e) { int seek = 0; switch (e.KeyCode) { case Keys.Enter: openMediaFileDialog.ShowDialog(); break; // 開く case Keys.Space: if (graph != null && !graph.IsPlaying) { graph.Play(); } else if (graph != null) { graph.Pause(); } break; // 再生/一時停止 case Keys.Escape: if (graph != null) { graph.Stop(); } break; // 停止 case Keys.Left: seek = -5000; break; // -5秒 case Keys.Right: seek = +5000; break; // +5秒 } if (seek != 0) { if (graph != null) { graph.CurrentPosition = Math.Max(0, graph.CurrentPosition + seek); } if (waveOut != null) { waveOut.Stop(); } } }