我每次调用时都会发出声音播放的方法:
public static void getInformationSound()
{
Uri uri = new Uri(@"pack://application:,,,/../Resources/Sounds/SF_Info.wav");
StreamResourceInfo sri = Application.GetResourceStream(uri);
SoundPlayer simpleSound = new SoundPlayer(sri.Stream);
simpleSound.Play();
}
但在SoundPlayer simpleSound = new SoundPlayer(sri.Stream);
行上我收到此错误:
对象引用未设置为对象的实例。
这是我的文件夹资源:
也许我错了URI? Project -> Resources (Folder) -> Sounds (Folder) -> file...
答案 0 :(得分:-1)
试试这个:
MediaPlayer mplayer = new MediaPlayer();
mplayer.Open(new Uri(@"../../Resources/Sounds/SF_Info.wav", UriKind.Relative));
mplayer.Play();