public void start()
{
if (captureSource == null)
{
// Create the VideoRecorder objects.
captureSource = new CaptureSource();
fileSink = new FileSink();
videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
// Add eventhandlers for captureSource.
captureSource.CaptureFailed += new EventHandler<ExceptionRoutedEventArgs>(OnCaptureFailed);
// Initialize the camera if it exists on the device.
if (videoCaptureDevice != null)
{
// Create the VideoBrush for the viewfinder.
videoRecorderBrush = new VideoBrush();
videoRecorderBrush.SetSource(captureSource);
videoRecorderBrush.RelativeTransform = new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 90 };
viewfinderRectangle.Fill = videoRecorderBrush;
// Start video capture and display it on the viewfinder.
captureSource.Start();
System.Diagnostics.Debug.WriteLine("Started");
_isRunning = true;
}
}
}