Basically I'm recording what is heard on my speakers like that
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();
and on key-press
speakersWaveIn.StopRecording();
waveFileWriter.Dispose();
which works perfectly. I am able to play the produced wav.-file with the Windows Media Player
.
However, when trying to play the file via
MediaFoundationReader reader = new MediaFoundationReader(filePath);
I get a System.Runtime.InteropServices.COMException: HRESULT: 0xC00D5212
.
User contributions licensed under CC BY-SA 3.0