我试着做一些非常基本的事情,但由于某些原因,它就是不点击。
这是我从资源中获取声音并将其保存为流的代码,这样我就可以将这些声音用于邪恶的目的。
/// Loads a wav file into an XNA Framework SoundEffect.
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);
soundEffectInstance = Sound.CreateInstance();
soundEffectInstance.IsLooped = true;
soundEffectInstance.Play();
}
catch (NullReferenceException)
{
// Display an error message
MessageBox.Show("Couldn't load sound " + SoundFilePath);
}
}尝试更改此代码,使文件来自我的服务器上的一个异常路径,而不是内部资源,但似乎什么都不起作用。我做错了什么?谢谢。
发布于 2012-01-11 20:56:55
您可以使用DynamicSoundEffectInstance播放字节数组中的声音。因此,将下载的声音保存为二进制文件,并在需要时使用它。
也许,这对你有帮助
https://stackoverflow.com/questions/8817949
复制相似问题