I have a part in my WinForms program that opens a second form with animation in a PictureBox and starts playing music through SoundPlayer. The problem is that after 0.5 seconds from the start of music playback, a loud white noise appears, music is not heard at all. Here is the code from this part:
private void timer1_Tick(object sender, EventArgs e)
{
i += 1;
progressBar1.Value = i;
if(i == 99)
{
timer1.Enabled = false;
SoundPlayer sp = new SoundPlayer(Properties.Resources.notsoimportant);
sp.Play();
MessageBox.Show("notsoimportant");
label1.Text = "notsoimportant";
button1.Text = "notsoimportant";
timer2.Enabled = true;
a = true;
SoundPlayer sp1 = new SoundPlayer(Properties.Resources.notsoimportant2);
sp1.Play();
Form2 f2 = new Form2();
}
}
private void timer2_Tick(object sender, EventArgs e)
{
i -= 1;
progressBar1.Value = i;
if (i == 0)
{
timer2.Enabled = false;
MessageBox.Show("notsoimportant");
}
}
It is enough to just declare the form, and it happens.
As I said, the second form has 1 timer and 1 PictureBox. All it does is render the GIF in full screen with switch case. If I remove Form2 f2 = new Form2 ();
, then there will be no white noise.