Example #1
0
 private void stopSong()
 {
     playButton.img    = playImg;
     playButton.imgLoc = new Point(size / 3, size / 4);
     playing           = false;
     player.Stop();
     timer.Stop();
 }
Example #2
0
        private static void GenerateJazz()
        {
            Random rnd = new Random();
            //var songLen = generator.generate(new SongParameters(1144069031, 128, "Jazz"));

            //var songLen = generator.generate(new SongParameters(rnd.Next(1044069031, 1344069031), rnd.Next(120, 150), "Twelve-tone"));
            var songLen = generator.generate(new SongParameters(rnd.Next(1044069031, 1344069031), 89, "Twelve-tone"));

            player.Open("temp.mid");
            player.Stop();
            player.Volume = -900;
            //player.Play();
        }
Example #3
0
        public override void Execute(List <Tuple <string, string> > param)
        {
            switch (param[0].Item1)
            {
            case "playpause":
            {
                player.PlayPause();
                break;
            }

            case "stop":
            {
                player.Stop();
                break;
            }

            case "next":
            {
                player.NextTitle();
                break;
            }

            case "prev":
            {
                player.PreviouseTitle();
                break;
            }

            case "louder":
            {
                player.IncreaseVolume();
                break;
            }

            case "quieter":
            {
                player.DecreaseVolume();
                break;
            }
            }
        }
Example #4
0
        private void tmrPiece_Tick(object sender, EventArgs e)
        {
            TimeSpan timer = DateTime.Now.Subtract(startTime);

            // Move the piece down
            tmrPiece.Interval = 120 - (tb.CheckLevel() - 1) * 10;
            tb.Update();

            // Update level, lines cleared, score and timer
            lblLevel.Text = "LEVEL\n" + Convert.ToString(tb.CheckLevel());
            lblLines.Text = "LINES\n" + Convert.ToString(tb.CheckLines());
            lblScore.Text = "SCORE\n" + Convert.ToString(tb.CheckScore());
            lblTimer.Text = string.Format("{0}:{1:00}", timer.Minutes, timer.Seconds);

            // If game is over
            if (tb.GameOver())
            {
                // Stop timers
                tmrPiece.Stop();
                tmrMusic.Stop();

                // Stop music, hide and close current form, open end form
                mp.Stop();
                this.Hide();
                this.Close();
                FrmEnd myGame = new FrmEnd(tb.CheckScore());
                myGame.ShowDialog();
            }

            // Check for line clears and play sound effect once
            if (tb.PlayEffect() == true)
            {
                sndClear.Play();
                tb.StopEffect();
            }

            // Redraw the game
            this.Invalidate();
        }
Example #5
0
 /// <summary>
 /// 停止
 /// </summary>
 public void Stop()
 {
     mediaPlayer.Stop();
 }
Example #6
0
 public void PlayBackgroundSound(string backgroundSoundPath)
 {
     _backgroundSoundPlayer.Stop();
     _backgroundSoundPlayer.Open(backgroundSoundPath);
     _backgroundSoundPlayer.Play();
 }
Example #7
0
        private void StartEffect(string EffectStream)
        {
            SoundPlayer player      = new SoundPlayer();
            var         mediaPlayer = new MediaPlayer.MediaPlayer();

            player.Stop();
            mediaPlayer.Stop();

            string[] codes       = EffectStream.Split('|');
            string   sEffectType = "";
            string   sEffect     = "";


            foreach (var code in codes)
            {
                if (code != "")
                {
                    sEffectType = code.Substring(0, 1);
                    sEffect     = CConfig.Instance.GetEffect(code);
                }

                try
                {
                    switch (sEffectType)
                    {
                    case "H":


                        if (sEffect.Contains("mp3"))
                        {
                            mediaPlayer.FileName = sEffect;
                            mediaPlayer.Play();
                        }
                        else
                        {
                            player.SoundLocation = sEffect;
                            player.Play();
                        }
                        break;

                    case "L":
                        int iBrightness1 = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Brightness1=") + "Brightness1=".Length, 3));
                        int iBrightness2 = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Brightness2=") + "Brightness2=".Length, 3));
                        int iSaturation1 = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Saturation1=") + "Saturation1=".Length, 3));
                        int iSaturation2 = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Saturation2=") + "Saturation2=".Length, 3));
                        int iHue1        = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Hue1=") + "Hue1=".Length, 5));
                        int iHue2        = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Hue2=") + "Hue2=".Length, 5));

                        HueLogic.PutBridge(1, true, iSaturation1, iBrightness1, iHue1);
                        HueLogic.PutBridge(2, true, iSaturation2, iBrightness2, iHue2);

                        break;

                    case "O":
                    case "A":
                        try
                        {
                            CConfig.Instance.InterfaceSerial.InterfaceSerialPort.Write(sEffect);
                        }
                        catch
                        {
                            CConfig.Instance.InterfaceSerial.InterfaceSerialPort.Close();
                            return;
                        }

                        break;

                    default:
                        break;
                    }
                }
                catch
                {
                }
            }
        }