【发布时间】:2018-12-30 08:17:13
【问题描述】:
我正在使用 NAudio 通过 Unity C# 读取和播放本地音频文件,但只要文件是 WMA 格式,Unity 就会崩溃。
我的代码适用于 Wav 和 Mp3 格式,只是 WMA 不起作用。
我尝试过使用专用的 MediaFoundationReader 和 WmaFileReader 类,也尝试过不同的 WavePlayer,例如 WaveOut 和 DirectSound,但我遇到了同样的问题。
我已经对多个 WMA 文件进行了尝试,这些文件的路径绝对正确。
这是我附加到 Unity 游戏对象的 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
感谢任何人提供的任何帮助,如果您需要更多信息,请告诉我!
【问题讨论】:
-
您只是想加载 WMA 音频并播放它?
-
是的,我只想播放 WMA 音频文件
-
您知道 NAudio 只能在 Windows 上运行吗?你的目标是什么操作系统?