public void PlaySound(string fileName)
        {
            //AudioFileReader input = new AudioFileReader(fileName);
            // potentially useless?

            CachedSound cachedSound = null;

            if (!cachedSounds.TryGetValue(fileName, out cachedSound))
            {
                cachedSound = new CachedSound(fileName);
                cachedSounds.Add(fileName, cachedSound);
            }

            PlaySound(cachedSound);
        }
예제 #2
0
        private void playSound(string file)
        {
            if (!XMLSettings.soundboardSettings.PlaySoundsOverEachOther)
            {
                stopPlayback();
            }

            try
            {
                //AudioPlaybackEngine.Primary.PlaySound(file);
                //AudioPlaybackEngine.Secondary.PlaySound(file);

                CachedSound cachedSound = null;

                if (!AudioPlaybackEngine.cachedSounds.TryGetValue(file, out cachedSound))
                {
                    cachedSound = new CachedSound(file);
                    AudioPlaybackEngine.cachedSounds.Add(file, cachedSound);
                }

                AudioPlaybackEngine.Primary.PlaySound(cachedSound);
                AudioPlaybackEngine.Secondary.PlaySound(cachedSound);
            }
            catch (FormatException ex)
            {
                SystemSounds.Beep.Play();
                MessageBox.Show(ex.ToString());
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                SystemSounds.Beep.Play();
                MessageBox.Show(ex.ToString());
            }
            catch (NAudio.MmException ex)
            {
                SystemSounds.Beep.Play();
                string msg = ex.ToString();
                MessageBox.Show((msg.Contains("UnspecifiedError calling waveOutOpen") ? "Something is wrong with either the sound you tried to play (" + file.Substring(file.LastIndexOf("\\") + 1) + ") (try converting it to another format) or your sound card driver\n\n" + msg : msg));
            }
        }
예제 #3
0
 public CachedSoundSampleProvider(CachedSound cachedSound)
 {
     this.cachedSound = cachedSound;
 }
 public void PlaySound(CachedSound sound)
 {
     AddMixerInput(new CachedSoundSampleProvider(sound));
 }