コード例 #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
ファイル: MainForm.cs プロジェクト: xiny120/rtmp-mediaplayer
        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;
            }
        }