Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CameraCaptureUI class

Applies to Windows only

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


public ref class CameraCaptureUI sealed 

Attributes

[MarshalingBehavior(None)]
[Threading(STA)]
[Version(0x06020000)]

Members

The CameraCaptureUI class has these types of members:

Constructors

The CameraCaptureUI class has these constructors.

ConstructorDescription
CameraCaptureUI Create a new CameraCaptureUI object.

 

Methods

The CameraCaptureUI class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
CaptureFileAsync Launches the CameraCaptureUI user interface.

 

Properties

The CameraCaptureUI class has these properties.

PropertyAccess typeDescription

PhotoSettings

Read-onlyProvides settings for capturing photos.

VideoSettings

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

 

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.

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

CameraCaptureUI is not supported in N editions of Windows 8. Attempts to create a CameraCaptureUI will fail. Apps that use CameraCaptureUI should handle this failure gracefully.

Note  Windows 8.1 N editions do not include certain media-related technologies.

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


This code shows how to use the CameraCaptureUI JavaScript object to take a picture. The code is from file capturephoto.js of the Camera capture UI sample. captureFileAsync is asynchronous and returns a Promise object. The dialog with the user occurs when the done method of the Promise object is called.


// 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");
});


Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

None supported

Namespace

Windows.Media.Capture
Windows::Media::Capture [C++]

Metadata

Windows.winmd

Capabilities

webcam
microphone

See also

Roadmaps
Adding multimedia to Windows Store apps using C++, C#, or Visual Basic
Adding multimedia to Windows Store apps using JavaScript
Samples
Camera capture UI sample
Camera options UI sample

 

 

Show:
© 2014 Microsoft