I am working on a Silverlight project to record the audio on a web page.
After I clicked the Pause button the code will always throw an exception:
Capture source is not stopped
If I put a break point on this line of code and wait there for 3-5 seconds then run the code, no exception will be threw.
if (audioSink.CaptureSource.State == CaptureState.Started) (break point is on this line)
Here is the code
private void Pause(object sender, RoutedEventArgs e)
{
//System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));
if (audioSink.CaptureSource.State == CaptureState.Started)
{
audioSink.CaptureSource.Stop();
this.btnPause.IsEnabled = false;
this.btnRecord.IsEnabled = true;
this.btnSave.IsEnabled = true;
}
}
audioSink.CaptureSource.Stop(); (This is the line of code which throws the exception)