5 simple steps to getting started with Camera in Windows Store App.

5 simple steps to getting started with Camera in Windows Store App.

MediaCapture class provides the functionalities for dealing with all kind of Audio and Video capturing in Windows Store Application. Using the properties and methods provided with this class, it is quite easy to capture audio and video . This Tip talk about simple steps to start building application using Camera in your windows store app.

Step 1 : Select Webcam in Capabilities in your Package.appxmanifest file .

Add Webcam in Capabilities in your Package.appxmanifest file

Step 2 :  Define the CaptureElement in XAML

<CaptureElement x:Name="captureElement"/>

Step 3: Initialize an object of MediaCapture class. You can find this under Windows. Media.Capture namespace.

MediaCapture mediaCapture = new MediaCapture();

await mediaCapture.InitializeAsync();

InitializeAsync() method, initialize the mediaCapture object using default settings ( MediaCaptureInitializationSettings)

Related Post :

Advanced handling of Photo Capture using PhotoCamera in Windows Phone

Working with CameraCaptureTask in Windows Phone

Step 4 : Once the  mediaCapture object initialized  you can set the Source property of CaptureElement with initialized mediaCapture instance.

captureElement.Source= mediaCapture;

Step 5.  Finally, Start the Video Preview by

await mediaCapture.StartPreviewAsync();

and Stop it using

await mediaCapture.StopeviewAsync();

By just following above steps, you should be able to see the video preview in your application. You just need to write the code block on approprite event handler, such as click on “Start Preview”, “Stop Preview” button on UI.

Subscribe To Newsletter For your Daily Development Tips and Tricks  

 Best Tips & Tricks on Microsoft Technology Platform 

Invalid email address
We promise not to spam you. You can unsubscribe at any time.
Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

One Comment to “5 simple steps to getting started with Camera in Windows Store App.”

Comments are closed.