Camera​Capture​UI Camera​Capture​UI Camera​Capture​UI Class

Definition

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.

public sealed class CameraCaptureUI : ICameraCaptureUIpublic sealed class CameraCaptureUI : ICameraCaptureUIPublic NotInheritable Class CameraCaptureUI Implements ICameraCaptureUI
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

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 to launch the UI. The user has control over when to start the capture. When the asynchronous CaptureFileAsync 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.

// 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

CameraCaptureUI() CameraCaptureUI() CameraCaptureUI()

Create a new CameraCaptureUI object.

public CameraCaptureUI()public CameraCaptureUI()Public Sub New()
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

After you create a new CameraCaptureUI object, you may want to set the PhotoSettings or VideoSettings property of the object before calling CaptureFileAsync.

Properties

PhotoSettings PhotoSettings PhotoSettings

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).

public CameraCaptureUIPhotoCaptureSettings PhotoSettings { get; }public CameraCaptureUIPhotoCaptureSettings PhotoSettings { get; }Public ReadOnly Property PhotoSettings As CameraCaptureUIPhotoCaptureSettings
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

For information on the available photo capture settings, see CameraCaptureUIPhotoCaptureSettings.

VideoSettings VideoSettings VideoSettings

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

public CameraCaptureUIVideoCaptureSettings VideoSettings { get; }public CameraCaptureUIVideoCaptureSettings VideoSettings { get; }Public ReadOnly Property VideoSettings As CameraCaptureUIVideoCaptureSettings
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

For information on the available video capture settings, see CameraCaptureUIVideoCaptureSettings.

Methods

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 )
Parameters
mode
CameraCaptureUIMode CameraCaptureUIMode 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.

Returns

When this operation completes, a StorageFile object is returned.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

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

See Also