Im creating a tick tack toe game in Visual Studio C# and have added sounds throughout the game already. I have just added a form to act as a messageBox for when the player levels up and have added my sound to the form_load...
The problem I am having is that when the player clicks OK and the messageBox form closes, the sound does not stop. I have tried all sorts but it just keeps rejecting me with those bloody red lines!!
I have also tried to open a new playGameForm (the form it returns to), which is what I have dont on the others but this is not ideal as when this form loads it has a sound of its own, and I do not want it to repeat that sound so soon during the users experience. Im sure I can use "something.Stop();" but dont know what the "something is"!!
Code: Select all
namespace TickTackToeAssignment
{
public partial class MessageBoxForm : Form
{
public MessageBoxForm()
{
InitializeComponent();
}
private void OkButtonMsgBox_Click(object sender, EventArgs e)
{
this.Close();
}
private void MessageBoxForm_Load(object sender, EventArgs e)
{
SoundPlayer heartBeat = new SoundPlayer();
heartBeat.SoundLocation = Application.StartupPath + "\\..\\..\\heartBeat.wav";
heartBeat.PlayLooping();
}
}
}