我目前正在为我的小游戏做一个选项菜单。例如,菜单具有启用音乐和声音的能力。
如果启用了音乐和声音,则会发生以下情况:
应该发生什么: 1.播放音乐2.如果你赢了3就开始播放声音。从音乐停止的地方播放音乐
现在,我检查是否选中了复选框,如果选中了,请播放“音乐”:
else if (enable_music.Checked && enable_sound.Checked && download_no)
{
//Store the State of the Application
Properties.Settings.Default.enable_music = true;
Properties.Settings.Default.enable_sounds = true;
//Load Music
SoundPlayer snd = new SoundPlayer(fileName_standard);
//We need to call the Sound only if we won or lost, so we save the Preference and call it in the Winscreen
Properties.Settings.Default.enable_sounds = true;
//Play the files
snd.Play();
Close();
}获胜的声音只有在显示屏幕时才会播放。
所以我想把音乐变成一种新的方法,然后称之为:
private async Task PlayMusic(SoundPlayer snd)
{
snd.Play();
}打电话:
else if(enable_darkmode.Checked && download_no)
{
SoundPlayer snd= new SoundPlayer(fileName_dark);
PlayMusic(snd);
Close();
}但是,如果其他文件开始播放,正常的音乐就停止了。那么,如果另一个文件正在播放,我如何让音乐暂停,并在文件停止播放时继续播放?
谢谢!
发布于 2016-05-19 00:17:16
使用分离的线程来运行独立的音乐播放实例,因此,在第二次运行时,orugunal可以暂停,而不需要插入暂停的音频。
https://stackoverflow.com/questions/37309142
复制相似问题