Ejemplo n.º 1
0
 private void btnSound_Click(object sender, EventArgs e)
 {
     MediaPlayer.MediaPlayer player = new MediaPlayer.MediaPlayer {
         FileName = (string)btnSound.Tag
     };
     player.Play();
     txtTranslation.Focus();
 }
 private static void PlayMp3(string mp3File)
 {
     Task.Run(() =>
     {
         var mediaPlayer = new MediaPlayer.MediaPlayer {FileName = mp3File};
         mediaPlayer.Play();
     });
 }
Ejemplo n.º 3
0
 private void playSong()
 {
     playButton.img         = pauseImg;
     playButton.imgLoc      = new Point(size / 4, size / 4);
     playing                = true;
     player.CurrentPosition = progress * songLen;
     player.Play();
     timer.Start();
 }
Ejemplo n.º 4
0
 private static void PlayMp3(string mp3File)
 {
     Task.Run(() =>
     {
         var mediaPlayer = new MediaPlayer.MediaPlayer {
             FileName = mp3File
         };
         mediaPlayer.Play();
     });
 }
Ejemplo n.º 5
0
        private void tmrMusic_Tick(object sender, EventArgs e)
        {
            // Replay the song once it is finished
            if (seconds % 85 == 0)
            {
                mp.Open(@"Resources\Tetris.mp3");
                mp.Play();
            }

            seconds++;
        }
        public bool play(MidiSelection e)
        {
            if (m_mediaPlayer != null)
            {
                // Setup and load the file into the media player
                m_mediaPlayer.FileName = fileNames[(int)e];
                m_mediaPlayer.Open(fileNames[(int)e]);

                // Play it
                m_mediaPlayer.Play();
            }
            return(true);
        }
        public void exibir_resultado(Double resultado)
        {
            if (resultado == 666)
            {
                MediaPlayer.MediaPlayer winmp = new MediaPlayer.MediaPlayer();
                winmp.FileName = @"123.mid";
                winmp.Open(winmp.FileName);
                winmp.Play();

                //SoundPlayer mp = new SoundPlayer(@"C:\Users\srmf32\Documents\Visual Studio 2013\Projects\Calculador Cientifica\Lavender_Town.wav");
                //mp.Play();
            }
            this.textBox = resultado.ToString();
        }
Ejemplo n.º 8
0
        private void button2_select_mp3_file_and_play_it_Click(object sender, EventArgs e)
        {
            //PLAYS A .MP3 FILE
            //SOURCE: http://csharpexamples.com/play-mp3-wav-files-synchronous-asynchronous-c/
            OpenFileDialog OPEN_FILE_DIALOG = new OpenFileDialog();

            if (OPEN_FILE_DIALOG.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string MP3_PATH = OPEN_FILE_DIALOG.FileName;

                var mediaPlayer = new MediaPlayer.MediaPlayer();
                mediaPlayer.FileName = MP3_PATH;
                mediaPlayer.Play();
            }
        }
        public frmAlarmFired(AlarmModel alarm)
        {
            InitializeComponent();

            this.alarm = alarm;

            lblName.Text        = $"Alarm: {alarm.Name}";
            textBoxMessage.Text = $"{alarm.Message}";
            lblAlarmTime.Text   = $"Set for: {alarm.AlarmDateTime}";

            //TODO do something better!
            var mediaPlayer = new MediaPlayer.MediaPlayer();

            mediaPlayer.FileName = @".\default.mp3";
            mediaPlayer.Play();

            UpdateLabels();
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 播放
 /// </summary>
 public void Play()
 {
     mediaPlayer.Play();
 }
Ejemplo n.º 11
0
 private void playSound()
 {
     wm.Open(soundPath + "sound.wma");
     wm.Play();
 }
Ejemplo n.º 12
0
 public void PlayBackgroundSound(string backgroundSoundPath)
 {
     _backgroundSoundPlayer.Stop();
     _backgroundSoundPlayer.Open(backgroundSoundPath);
     _backgroundSoundPlayer.Play();
 }
Ejemplo n.º 13
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
                {
                }
            }
        }
        public void exibir_resultado(Double resultado)
        {
            if (resultado == 666)
            {
                MediaPlayer.MediaPlayer winmp = new MediaPlayer.MediaPlayer();
                winmp.FileName = @"123.mid";
                winmp.Open(winmp.FileName);
                winmp.Play();

                //SoundPlayer mp = new SoundPlayer(@"C:\Users\srmf32\Documents\Visual Studio 2013\Projects\Calculador Cientifica\Lavender_Town.wav");
                //mp.Play();
            }
            this.textBox = resultado.ToString();
        }