Before reading this article, please go through the following articles:
IntroductionIn my last article in this series we saw how to create a global app bar for a Windows Store app. In this article we will see how to use a webcam or any other capture device to preview the video in a Windows Store app. Assume you are developing an application related to photo sharing and you need to first capture the image and then share this captured image with other users. For that we need to use our system's capture devices. To use a webcam or capture device we need to modify some settings. In this article we will see how to make our Windows Store application that can use a webcam or any other capture device. To make a webcam enabled in a Windows Store app have a look at the following procedure.
Step 1I'm assuming you know how to create a basic Windows Store application using Visual Studio 2012. First create a Windows Store application.
Step 2Next open the manifest file from the Solution Explorer by double-clicking on the "package.appxmanifest" file. In this file we have to set the capabilities for accessing the webcam in our Windows Store application.
Step 3Go to the capabilities tab in the manifest file and check the checkbox for the webcam or capture device of which access is to be enabled. For more capabilities see this article.
Step 4After adding the capability for the webcam we need the control on our page for showing a preview of the captured video from the webcam. In the Windows Store app we have a new control to do that called CaptureElement. Add captureelement onto your page like the following:
<CaptureElement Name="capturePreview" Height="400" />
Step 5After adding a capture element, we need to create an object of the MediaCapture class that contains methods and properties related to capturing video. Create the object like the following and initialize it.
MediaCapture captureMgr = new MediaCapture();
await captureMgr.InitializeAsync();
Step 6The last thing to do to complete our work is to assign the source to our CaptureElement added in Step 4 to the MediaCapture object and start previewing it in the CaptureElement.
capturePreview.Source = captureMgr;
await captureMgr.StartPreviewAsync();
Step 7Next run your application and see the live video from you webcam in your Windows Store application.
ConclusionUsing a simple way we can create a video capturing application using a Windows Store app.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: