我在WinForms程序中扮演了一个角色,该程序在PictureBox中打开第二个带有动画的表格,并开始通过SoundPlayer播放音乐。问题是,从播放音乐开始0.5秒后,出现很大的白噪声,根本听不到音乐。 这是此部分中的代码:
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");
}
}
仅声明表单就足够了,它发生了。
如我所说,第二种形式有1个计时器和1个PictureBox。它所做的就是在带有开关盒的情况下全屏显示GIF。如果我移除Form2 f2 = new Form2 ();
,那么将不会有白噪声。