Hi, i have an error when the proyect starts to record, this is the code:
WasapiLoopbackCapture waveInStream;
WaveFileWriter writer;
bool isRecording = false;
private void cmdRecord_Click(object sender, System.EventArgs e)
{
if (isRecording == false)
{
this.Enabled = false;
saveFileDialog1.Filter = "Wav Files (*.wav)|*.wav";
DialogResult result = saveFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string RutaAGrabar = saveFileDialog1.FileName;
waveInStream = new WasapiLoopbackCapture();
writer = new WaveFileWriter(RutaAGrabar, waveInStream.WaveFormat);
waveInStream.DataAvailable += new System.EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);
waveInStream.StartRecording();// the error is here,
isRecording = true;
}
this.Enabled = true;
}
else
{
waveInStream.StopRecording();
waveInStream.Dispose();
waveInStream = null;
writer.Close();
writer = null;
IsRecording = false;
}
}
void waveInStream_DataAvailable(object sender, WaveInEventArgs e)
{
writer.WriteData(e.Buffer, 0, e.BytesRecorded);
}
thanks for any help
Comments: that's unusual. What OS are you using?
WasapiLoopbackCapture waveInStream;
WaveFileWriter writer;
bool isRecording = false;
private void cmdRecord_Click(object sender, System.EventArgs e)
{
if (isRecording == false)
{
this.Enabled = false;
saveFileDialog1.Filter = "Wav Files (*.wav)|*.wav";
DialogResult result = saveFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string RutaAGrabar = saveFileDialog1.FileName;
waveInStream = new WasapiLoopbackCapture();
writer = new WaveFileWriter(RutaAGrabar, waveInStream.WaveFormat);
waveInStream.DataAvailable += new System.EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);
waveInStream.StartRecording();// the error is here,
isRecording = true;
}
this.Enabled = true;
}
else
{
waveInStream.StopRecording();
waveInStream.Dispose();
waveInStream = null;
writer.Close();
writer = null;
IsRecording = false;
}
}
void waveInStream_DataAvailable(object sender, WaveInEventArgs e)
{
writer.WriteData(e.Buffer, 0, e.BytesRecorded);
}
thanks for any help
Comments: that's unusual. What OS are you using?