Connect to a Camera Device
If you have more than one camera devices, you can specify which device to use. The code snippet below demonstrates how to get the video and audio devices and initialize the camera with them.
The RadWebCam.AutoStart property should be set to false if you want to initialize it with a specific camera device.
To connect to a web cam manually, execute the following steps:
- Get the camera device. To do this, use the RadWebCam.GetVideoCaptureDevices static method.
- Get a video format from the camera. To do this, use the RadWebCam.GetVideoFormats static method.
- Initialize the camera device in the control. To do this, use the Initialize method of the RadWebCam control.
- Start the web cam control. To do this, use the Start method of the control.
The manual initialization of RadWebCam should be executed after the control gets loaded. For example, you can use the form's Load event.
ReadOnlyCollection<MediaFoundationDeviceInfo> videoDevices = RadWebCam.GetVideoCaptureDevices();
ReadOnlyCollection<MediaFoundationVideoFormatInfo> videoFormats = RadWebCam.GetVideoFormats(videoDevices[1], true);
ReadOnlyCollection<MediaFoundationDeviceInfo> audioDevices = RadWebCam.GetAudioCaptureDevices();
radWebCam1.Initialize(videoDevices[1], videoFormats[9], audioDevices[1]);
radWebCam1.Start();
Dim videoDevices As ReadOnlyCollection(Of MediaFoundationDeviceInfo) = RadWebCam.GetVideoCaptureDevices()
Dim videoFormats As ReadOnlyCollection(Of MediaFoundationVideoFormatInfo) = RadWebCam.GetVideoFormats(videoDevices(1), True)
Dim audioDevices As ReadOnlyCollection(Of MediaFoundationDeviceInfo) = RadWebCam.GetAudioCaptureDevices()
radWebCam1.Initialize(videoDevices(1), videoFormats(9), audioDevices(1))
radWebCam1.Start()