我使用以下代码段来播放.wav文件:
Stream s = TitleContainer.OpenStream("sounds/MySound.wav");
SoundEffect effect = SoundEffect.FromStream(s);
FrameworkDispatcher.Update();
effect.Play();
有没有办法在开始播放后停止声音?
答案 0 :(得分:0)
从SoundEffectInstance
创建SoundEffect
,然后您就可以访问更多操作来控制声音了。
Stream s = TitleContainer.OpenStream("sounds/MySound.wav");
SoundEffect effect = SoundEffect.FromStream(s);
var effectInstance = effect.CreateInstance();
FrameworkDispatcher.Update();
effectInstance.Play();
// This will stop the sound
effectInstance.Stop();