So I am using a win form application using the latest framework for c#.
Here I have a button that plays a sound (asterisk) and then after 5 secs or 20 secs(I let the user pick) I want it to play a different sound (beep in this case) But when it calls the code to play beep the sound I hear is Asterisk.
finally at the end I want another sound to signal that it has finished. I have chosen (Exclamation) but again I hear asterisk.
Does anyone know why I would only hear the one sound?
P.S. I have tried switching the start sound to beep and the "next" sound to asterisk. I clean and rebuild but then the only sound I hear is a beep.
Here is the code behind for the button click
private void btnStart_Click(object sender, EventArgs e)
{
BusinessLayer.ToneApp.PlaySound play = new BusinessLayer.ToneApp.PlaySound();
_countDown = play.IsValid(txtTime.Text);
numreps = play.IsValid(txtReps.Text);
numsets = play.IsValid(txtSets.Text);
lblFinished.Text = "";
play.PlaySoundStart();
_timer = new System.Windows.Forms.Timer();
_timer.Enabled = true;
_timer.Tick += new EventHandler(timer1_Tick);
_timer.Interval = 1000;
_timer.Start();
}
in the timer1_tick event I have
private void timer1_Tick(object sender, EventArgs e)
{
BusinessLayer.ToneApp.PlaySound play = new BusinessLayer.ToneApp.PlaySound();
_countDown--;
if (_countDown < 1)
{
//my code
play.PlaySoundNext();
}
}
and finally here is my playsound
public class PlaySound
{
public void PlaySoundStart()
{
System.Media.SystemSounds.Asterisk.Play();
}
public void PlaySoundNext()
{
System.Media.SystemSounds.Beep.Play();
}
public void PlaySoundStop()
{
System.Media.SystemSounds.Exclamation.Play();
}
public int IsValid(string textToInt)
{
int.TryParse(textToInt, out int timeInSeconds);
return timeInSeconds;
}
}