HTML and CSS Reference
In-Depth Information
dialog.photoSettings.croppedAspectRatio = aspectRatio;
dialog.photoSettings.format = Windows.Media.Capture.
CameraCaptureUIPhotoFormat.jpeg;
dialog.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo)
.then(
function (file) {
// More code here
},
function (err) {
// User canceled the operation.
}
);
}
catch (err) {
// Show some error message.
}
}
As you can see, the core of the capture operation is the captureFileAsync method exposed by the
CameraCaptureUI object. The method takes just one argument that controls whether you want to use
the camera to take a picture or shoot a video.
dialog.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(...);
The method works asynchronously, so to work on its results you need to arrange a JavaScript
then or done promise that receives the byte stream of the captured image. Figure 12-2 shows the
application in action.
FIGURE 12-2 The webcam application ready to take a picture.
Search WWH ::




Custom Search