示例#1
0
        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");
        }
示例#2
0
 /// <summary>
 /// Stop musicplayer
 /// </summary>
 public void Stop()
 {
     if (State != PlayerState.Stop)
     {
         Mediaplayer.Stop();
         State = PlayerState.Stop;
     }
 }
示例#3
0
 private void lbPlaylist_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (mediaplayer != null && lbPlaylist.SelectedIndex >= 0)
     {
         bool addToPreviousHistory = (mediaplayer.IsPlaying || mediaplayer.IsPausing);
         mediaplayer.Stop();
         mediaplayer.ChangeCurrentMediaItemIndex(lbPlaylist.SelectedIndex, addToPreviousHistory);
         mediaplayer.Play();
     }
 }