基本上我记录了我的扬声器上听到的内容
speakersWaveIn = new WasapiLoopbackCapture(); //class variable
waveFileWriter = new WaveFileWriter(filepath, speakersWaveIn.WaveFormat); //class variable
speakersWaveIn.DataAvailable += speakersWaveIn_DataAvailable;
speakersWaveIn.RecordingStopped += speakersWaveIn_RecordingStopped;
speakersWaveIn.StartRecording();
speakersWaveIn_DataAvailable
waveFileWriter.Write(e.Buffer, 0, e.BytesRecorded);
waveFileWriter.Flush();
并按键
speakersWaveIn.StopRecording();
waveFileWriter.Dispose();
完美无缺。我可以使用Windows Media Player
播放生成的wav.-文件。
但是,尝试通过
播放文件时MediaFoundationReader reader = new MediaFoundationReader(filePath);
我得到System.Runtime.InteropServices.COMException: HRESULT: 0xC00D5212
。