Silverlight video and voice Basic Applications

Source: Internet
Author: User

One of the exciting features of Silverlight 4 is the support for video and voice devices. The following describes how to use it:

1. List the video and voice devices:

A) The video uses system. Windows. Media. capturedeviceconfiguration. getavailablevideocapturedevices () to obtain the list of available video devices on the current computer. A collection of devices is returned.

B) The system. Windows. Media. capturedeviceconfiguration. getavailableaudiocapturedevices () method is used to obtain the list of available audio devices on the current computer. The returned result is a collection of audio and audio devices.

* The set obtained above can be placed in a ComboBox, allowing users to select and use it in practical applications.

2. Obtain the default device:

A) You can set the default audio and video devices of Silverlight. This option can be activated by right-clicking Silverlight.

B) directly obtain the default audio and video devices:

// Obtain the default audio device

System. Windows. Media. capturedeviceconfiguration. getdefaauaudiocapturedevice ();

// Obtain the default video device
System. Windows. Media. capturedeviceconfiguration. getdefavidevideocapturedevice ();

3. Obtain the streaming Coal:

A) XAML defines a rectangle for video rendering:

 <Rectangle x:Name="WebcamCapture" Width="320" Height="240" Fill="White"/>
 

B) C # code:

// Instantiate an audio/video source
                CaptureSource cs = new CaptureSource();
                cs.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
                cs.AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice();
 
                VideoBrush vidBrush = new VideoBrush();
                vidBrush.SetSource(cs);
// Webcamcapture is rectangle
                WebcamCapture.Fill = vidBrush; 
 
// Obtain the user's permission to access audio and video devices
                if (CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess())
                {
// Start stream Extraction
                    _captureSource.Start();
                }
 

. After running the video, you can extract the stream. The content of the camera will be displayed in the webcamcature rectangle in real time.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.