MediaFoundationReader throws exception when playing recorded .wav file

0

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.

c#
naudio
asked on Stack Overflow Nov 5, 2015 by VGD • edited Nov 5, 2015 by Atish Dipongkor

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0