Getting Audio and Video Devices Information in Silverlight


Getting Devices Information

CaptureDeviceConfiguration with the help of its six static members are used to get information about available audio and video capture devices. This class also provides methods to set and request client user permission to access the captures from available devices.

GetAvailableAudioCaptureDevices and GetAvailableVideoCaptureDevices methods return all available audio and video capture devices on a machine.

GetDefaultAudioCaptureDevice and GetDefaultVideoCaptureDevice methods return default audio and video capture devices on a machine.

RequestDeviceAccess method requests access for all possible audio or video capture devices that are available on a machine. AllowedDeviceAccess returns a value that reports whether a user has previously granted device access based on their stored response to the device access UI prompt.

The code snippet in Listing 1 uses these methods to display available audio and video devices in ComboBox controls. Here AudioDevices and VideoDevices are two ComboBox controls.

// Get all available audio and video devices and display in ComboBoxes

AudioDevices.ItemsSource = CaptureDeviceConfiguration.GetAvailableAudioCaptureDevices();

VideoDevices.ItemsSource = CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices();

 

// Get default audio and video devices and select them by default

AudioCaptureDevice defaultAudio = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice();

VideoCaptureDevice defaultVideo = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

 

Listing 1

To test this code, create a Silverlight 4 application using Visual Studio 2010 and add two ComboBox controls and change their Name property to AudioDevices and VideoDevices. After that, write this code on the page load event handler.



Similar Articles
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.