CameraCaptureUI CameraCaptureUI CameraCaptureUI CameraCaptureUI Class

Provides a full window UI for capturing audio, video, and photos from a camera. As well as controls for trimming video, time delayed capture, and camera settings.

Syntax

Declaration

public sealed class CameraCaptureUIpublic sealed class CameraCaptureUIPublic NotInheritable Class CameraCaptureUIpublic sealed class CameraCaptureUI

Remarks

CameraCaptureUI provides a full window UI experience for capturing audio, video, and images. It provides controls for setting a time delay on photo captures, trimming video, and for adjusting the camera's settings such as video resolution, the audio device, brightness, and contrast.

Call CaptureFileAsync(CameraCaptureUIMode) to launch the UI. The user has control over when to start the capture. When the asynchronous CaptureFileAsync(CameraCaptureUIMode) operation completes, a StorageFile object is returned. For how-to guidance for using CameraCaptureUI, see Capture photos and video with Windows built-in camera UI

Note

You should not specify the webcam or microphone capabilities in your app manifest file if you are using CameraCaptureUI. If you do so, your app will be displayed in the device's camera privacy settings, but even if the user denies camera access to your app, it will not prevent the CameraCaptureUI from capturing media. This is because the Windows built-in camera app is a trusted first-party app that requires the user to initiate photo, audio, and video capture with a button press. Your app may fail WACK (Windows Application Certification Kit) certification when submitted to the Store if you specify the webcam or microphone capabilities when using CameraCaptureUI.

You must specify the webcam or microphone capabilities in your app manifest file if you are using MediaCapture to capture audio, photos, or video programmatically.

Note

This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).

Examples

This code shows how to use the CameraCaptureUI class to take a picture. The code is from file CapturePhoto.xaml.cs of the Camera capture UI sample. The dialog with the user occurs when you call the asynchronous method CaptureFileAsync(CameraCaptureUIMode).

// Using Windows.Media.Capture.CameraCaptureUI API to capture a photo
CameraCaptureUI dialog = new CameraCaptureUI();
Size aspectRatio = new Size(16, 9);
dialog.PhotoSettings.CroppedAspectRatio = aspectRatio;

StorageFile file = await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo);
// Using Windows.Media.Capture.CameraCaptureUI API to capture a photo
var dialog = new Windows.Media.Capture.CameraCaptureUI();
var aspectRatio = { width: 1, height: 1 };
dialog.photoSettings.croppedAspectRatio = aspectRatio;
dialog.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).done(function (file) {
    if (file) {
        var photoBlobUrl = URL.createObjectURL(file, { oneTimeOnly: true });
        document.getElementById("capturedPhoto").src = photoBlobUrl;
        document.getElementById("resetButton").style.visibility = "visible";
        localSettings.values[photoKey] = file.path;
    } else {
        WinJS.log && WinJS.log("No photo captured.", "sample", "status");
    }
}, function (err) {
    WinJS.log && WinJS.log(err, "sample", "error");
});

Constructors summary

Create a new CameraCaptureUI object.

Properties summary

Provides settings for capturing photos. The settings include aspect ratio, image size, format, resolution, and whether or not cropping is allowed by the user interface (UI).

Provides settings for capturing videos. The settings include format, maximum resolution, maximum duration, and whether or not to allow trimming.

Methods summary

Launches the CameraCaptureUI user interface.

Constructors

Properties

Methods

  • CaptureFileAsync(CameraCaptureUIMode)
    CaptureFileAsync(CameraCaptureUIMode)
    CaptureFileAsync(CameraCaptureUIMode)
    CaptureFileAsync(CameraCaptureUIMode)

    Launches the CameraCaptureUI user interface.

    public IAsyncOperation<StorageFile> CaptureFileAsync(CameraCaptureUIMode mode)public IAsyncOperation<StorageFile> CaptureFileAsync(CameraCaptureUIMode mode)Public Function CaptureFileAsync(mode As CameraCaptureUIMode) As IAsyncOperation( Of StorageFile )public IAsyncOperation<StorageFile> CaptureFileAsync(CameraCaptureUIMode mode)

    Parameters

    Returns

    • When this operation completes, a StorageFile object is returned.

    Remarks

    Call CaptureFileAsync(CameraCaptureUIMode) to launch the UI. The user has control over when to start the capture. When the asynchronous operation completes, a StorageFile object is returned.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Capabilities

microphone
webcam

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.Media.Capture.dll