我正在尝试使用NAudio和MS Media Foundation编解码器播放.flac音乐文件。但是,无论何时歌曲到达末尾或接近末尾,都会引发异常。有什么方法可以修复它,或者有其他方法可以演奏吗?
抛出异常
System.Runtime.InteropServices.COMException (0xC00D36E3): Exception from HRESULT: 0xC00D36E3
加载和播放音乐的代码
readerStream = new MediaFoundationReader(FilePath);
waveChannel = new WaveChannel32(readerStream);
readerStream = new DSPEffectStream(waveChannel, m_eqEffect);
postVolumeMeter = new MeteringSampleProvider(readerStream.ToSampleProvider());
waveOutDevice.Init(postVolumeMeter, true);
waveOutDevice.Play();
我发现有些人也有类似的问题,但没有解决方法。 Discussion link
最佳答案
0xC00D36E3是 MF_E_BAD_STARTUP_VERSION
"You are calling MFStartup with the wrong MF_VERSION. Mismatched bits?"。依次means:
If MFStartup returns MF_E_BAD_STARTUP_VERSION, it means your application was compiled using a version of the Media Foundation headers that does not match the Media Foundation DLLs on your system.
该问题应该与Media Foundation初始化有关,并且您没有明确进行初始化,那么NAudio可能会以某种方式不正确地进行初始化(或过早取消初始化)。
关于audio - 使用MediaFoundationReader时出现COMException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26316736/