以下是我现在正在播放的设置。鉴于此,我怎么知道_BGMusic SoundEfect何时结束?我正在运行一个游戏循环,每秒循环几次,我最终想要循环播放这首歌曲。如何检查音效是否正在播放(循环播放BG歌曲)
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
SoundEffect _BGMUSIC;
public Page1() {
...
LoadSound("sfx/piano.wav", out _BGMUSIC);
...
}
private void LoadSound(String SoundFilePath, out SoundEffect Sound) {
// For error checking, assume we'll fail to load the file.
Sound = null;
try {
// Holds informations about a file stream.
StreamResourceInfo SoundFileInfo =
App.GetResourceStream(new Uri(SoundFilePath, UriKind.Relative));
// Create the SoundEffect from the Stream
Sound = SoundEffect.FromStream(SoundFileInfo.Stream);
FrameworkDispatcher.Update();
} catch (NullReferenceException) {
// Display an error message
MessageBox.Show("Couldn't load sound " + SoundFilePath);
}
}
你有没有找到解决这个问题呢? – tmwoods 2013-03-06 16:05:19
我还没有解决方案 – 2013-03-06 16:37:42