Creates an operation object for displaying the dialog that captures a photo or video.
Syntax
cameraCaptureUI.captureFileAsync(mode).done( /* Your success and error handlers */ );
Parameters
- mode
-
Type: CameraCaptureUIMode
Specifies whether the user interface that will be shown allows the user to capture a photo, capture a video, or capture both photos and videos.
Return value
Type: IAsyncOperation<StorageFile>
The operation that displays the user interface.
Examples
The following example calls CaptureFileAsync, and displays a message that indicates if the capture was successful.
// Take a photo using the default JPEG format. function takepicture() { var captureUI = new Windows.Media.Capture.CameraCaptureUI(); captureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (capturedItem) { if (capturedItem) { document.getElementById("message").innerHTML = "User captured a photo." } else { document.getElementById("message").innerHTML = "User didn't capture a photo." } }); }
The following example shows how to set the properties of VideoSettings, and then how to call CaptureFileAsync to capture a video.
// Captures a video using the specified settings. function captureVideo() { var captureUI = new Windows.Media.Capture.CameraCaptureUI(); captureUI.videoSettings.allowTrimming = true; captureUI.videoSettings.format = Windows.Media.Capture.CameraCaptureUIVideoFormat.wmv; captureUI.videoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxVideoResolution.standardDefinition; captureUI.videoSettings.maxDurationInSeconds = 3; captureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.video).then(function (file) { if (file) { document.getElementById("message").innerHTML = "User captured a video." } else { document.getElementById("message").innerHTML = "User didn't capture a video." } }); }
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Namespace |
|
|
Metadata |
|
|
Capabilities |
|
See also
Build date: 12/4/2012