I want a sound player to play as long as a button is pressed.
Here is what I've done so far :
public partial class Form1 : Form
{
private SoundPlayer soundPlayer;
private void FormMain_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == 'n')
{
SoundPlayer s = new SoundPlayer(@"C:\Users\darude_rig\Desktop\dayz sounboard\media\sounds\AKM.wav");
s.PlayLooping();
}
}
}
Where is the problem and how can I fix it?