public void stop()
{
if (captureSource != null)
{
// Stop captureSource if it is running.
if (captureSource.VideoCaptureDevice != null
&& captureSource.State == CaptureState.Started)
{
captureSource.Stop();
}
// Remove the event handler for captureSource.
captureSource.CaptureFailed -= OnCaptureFailed;
// Remove the video recording objects.
captureSource = null;
videoCaptureDevice = null;
fileSink = null;
videoRecorderBrush = null;
System.Diagnostics.Debug.WriteLine("Stopped");
_isRunning = false;
}
}