标题的真正含义是:现在我只知道如何使用.Play和.Stop控制声音,但是有一种方法可以使声音静音但仍在后台播放?
这是代码片段:
private void muteButton_Click(object sender, EventArgs e)
{
if (muteButton.Text == "Mute")
{
muteButton.Text = "Unmute";
_soundPlayer.Stop();
}
else
{
muteButton.Text = "Mute";
_soundPlayer.PlayLooping();
}
}
最佳答案
你应该试试这个
private boolean playing = true;
private void muteButton_Click(object sender, EventArgs e)
{
if (_soundPlayer.IsLoadCompleted)
{
if (playing)
{
_soundPlayer.Stop();
playing = false;
}
else
{
_soundPlayer.Play();
playing = true;
}
}
}
关于c# - 有什么方法可以使声音静音但又可以使其在后台运行而不是完全停止播放?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21296390/