1

I have a SoundPlayer in my form which plays under specific KeyDown conditions. On my Windows 8.1 computer, if the key is held down, the sound repetitively plays (sometimes not even finishing before it plays again) but on all the other computers I have tried it on, which are Windows 7, the SoundPlayer only plays once, and usually not even until after the key is up. Is this supposed to happen or am I missing something in my code? The Windows 8.1 behaviour is my desired behaviour on all systems. Here is my code:

SoundPlayer blip = new SoundPlayer(Properties.Resources.Blip);

public void Form1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Down || e.KeyCode == Keys.S)
            {
                Blip();
            }
}

public void Blip()
        {
            blip.Play();
        }
Kelyn Ferguson
  • 143
  • 2
  • 7
  • so is this a problem with the key event or the player code? posing your code will help a lot – sa_ddam213 Aug 14 '14 at 03:00
  • I added the code even though I doubt it will help much considering it's pretty basic. That's actually what I'm trying to find out: whether this is the key event, the SoundPlayer, or just a difference between the way operating systems handle things. – Kelyn Ferguson Aug 14 '14 at 03:05
  • 1
    maybe add some logging and find out if its the event firing or soundplayer running async – sa_ddam213 Aug 14 '14 at 03:09

0 Answers0