The silver light of the Silverlight4.0 tutorial with the camera and Mike Wind device interaction

Source: Internet
Author: User
Tags new set silver light silverlight visual studio 2010

Microsoft released the Silverlight 4 beta on PDC2009, and Microsoft processed about 8,000 Silverlight end-user requests in the Silverlight 4 release, adding a new set of features that were exciting for developers, most notably in several ways:

Development Tools Enhancements: Visual Studio 2010 has a visual design tool that allows you to choose whether the runtime version is 3.0 or 4.0,blend4 to add XAML and C # code to the full range of IntelliSense features, XAML style apps are easier to use, and more.

Camera and MIC hardware support: Enables user-native webcam and mic with minimal code, and allows for local recording.

Report Printing support: report printing problems in the SILVERLIGHT4 to get a better solution.

More powerful base class controls (RichTextBox, DataGrid-enhanced): Rich Text control RichTextBox and DataGrid with paste, sort function are added.

WCF enhancement: Finally, TCP communication is supported, compared with HTTP elevation 3-5 times, limited to 4502-4534 ports.

Compatibility enhancement: Support for Google's Chrome browser.

MEF Support: MEF is all called the Managed Extensibility Framework, translated as "Managed Extensions framework", supporting the creation of large and complex applications.

Operating speed: The boot speed and rendering speed is about twice times higher than the previous version.

DRM enhancement: Supports PlayReady, which protects the playback of video and audio, and complements the DRM protection of H.

Other enhancements: Local file read/write, right mouse button event support, clipboard support.

When the user installs the Silverlight 4.0 runtime, open the browser in any Silverlight application by clicking the right mouse button to see the properties of the Silverlight4 plugin, which joins the tab entry for webcam and mic support, as shown in the figure.

Silverlight 4.0 of capturedeviceconfiguration.getavailablevideocapturedevices can get a list of all the available camera devices in the user's native, below we implement enable the user native camera in Silverlight, first add in the interface A "container" Grid to display the video, and then add a button to enable the Cam device, as shown in the figure.

Xaml:1 < Border x:name = "LayoutRoot" Cornerradius = "5"
2 BorderBrush = "Gray" borderthickness = "3" >
3 < Border.background >
4 < VideoBrush x:name = "Myvideobrush"/>
5 </border.background >
6 < Button x:name = "Btncam" HorizontalAlignment = "Right"
7 VerticalAlignment = "Bottom"
8 Width = "Height" = "30"
9 Content = "Start Camera"/>
</border >

C #: 1 public Videoandaudio ()
2 {
3 InitializeComponent ();
4 this. Btncam. Click + = new Routedeventhandler (Btncam_click);
5}
6
7 void Btncam_click (object sender, RoutedEventArgs e)
8 {
9//Get default Video Device object
Ten Videocapturedevice cam = capturedeviceconfiguration. Getdefaultvideocapturedevice ();
11//Create video Capture source object
Capturesource VideoSource = new Capturesource ();
13//Get permission to enable a native camera for the user
if (capturedeviceconfiguration. Requestdeviceaccess ())
15 {
16//Set up a video device
VideoSource. Videocapturedevice = Cam;
18//Set Video source
Myvideobrush. SetSource (VideoSource);
Myvideobrush. Stretch = Stretch. Fill;
21//Boot camera
VideoSource. Start ();
23}
24}

When you click the Enable camera button, Silverlight prompts the user to allow the application to access your native video device.

After the user chooses is, the user's video content will immediately display in Border's VideoBrush area, is not very easy.

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.