c# - 当我尝试在 C# WinForms 中打开第二个表单时,声音播放器中出现白噪声
问题描述
我在我的 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 ();
,则不会有白噪声。
解决方案
推荐阅读
- angular - 如何使用 angular 7 和 bootstrap 4 逐步构建代码以形成表单?
- ruby-on-rails - 迭代合并的 AssociationRelation
- javascript - Angular 6:使用 .addControl 附加子表单组
- c++ - PCL 估计尖角处的法线给出弯曲的结果
- batch-file - 如果存在多个通配符
- azure - 通过 Powershell Runbook 从 ARM 模板部署 Azrue VM,无需下载模板
- javascript - C#,如何对 JObject 值中的字符进行转义?
- swift - macOS 中按键按下的 NSEvent 泄漏
- quarkus - 如何在 Quarkus 中为我的 RESTEasy 资源设置基本路径?
- laravel - Phpunit 在 laravel 5.5 上没有这样的文件或目录