我正在使用NAudio通过Unity C#阅读和播放本地音频文件,但只要文件是WMA格式,Unity就会崩溃。
我的代码适用于Wav和Mp3格式,只是WMA不起作用。
我试过使用专用的MediaFoundationReader和WmaFileReader类,也试过不同的WavePlayers,比如WaveOut和DirectSound,但我遇到了同样的问题。
我已经在多个WMA文件上尝试过了,我指向这些文件的路径绝对是正确的。
这是我附加到Unity GameObject上的C#脚本:
output = new WaveOutEvent();
reader = new AudioFileReader(path); //This is the line that it crashes on
output.PlaybackStopped += PlayBackStopped;
output.Init(reader);
output.Play();A full example of the code can be found here
A Unity crash dump can be found here
感谢任何人能提供的任何帮助,如果你需要更多的信息,请告诉我!
发布于 2018-07-23 15:02:38
Unity支持导入以下音频文件格式:.aif、.wav、.mp3和.ogg https://docs.unity3d.com/Manual/AudioFiles.html
https://stackoverflow.com/questions/51469299
复制相似问题