private void ExecMenu() { string ch = "\0"; do { ch = Console.ReadKey(true).KeyChar.ToString().ToUpper(); switch (ch) { case "P": //play/pause if (mediaplayer.IsStopped || mediaplayer.IsPausing) { mediaplayer.Play(); } else if (mediaplayer.IsPlaying) { mediaplayer.Pause(); } break; case "Z": //stop if (mediaplayer.IsPlaying || mediaplayer.IsPausing) { mediaplayer.Stop(); } break; case ",": case "<": // previous mediaplayer.Previous(); break; case ".": case ">": // next mediaplayer.Next(); break; case "S": // Seek if (mediaplayer.IsPlaying) { mediaplayer.Seek(15 * 1000); } break; case "+": if (mediaplayer.Volume < 100) { mediaplayer.Volume = Convert.ToByte(mediaplayer.Volume + 1); } break; case "-": if (mediaplayer.Volume > 0) { mediaplayer.Volume = Convert.ToByte(mediaplayer.Volume - 1); } break; } //switch } while (ch != "Q"); }
private void tbProgress_MouseUp(object sender, MouseEventArgs e) { if (mediaplayer == null) { return; } try { // set new location if (mediaplayer.IsPlaying) { long posInMS = Convert.ToInt64((mediaplayer.DurationInMS * tbProgress.Value) / tbProgress.Maximum); mediaplayer.Seek(posInMS); } } finally { // importnt do as last progressIsDragged = false; } }