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 .
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.
Pingback: Dealing with Front and Rear Camera in Windows Store Application