Skip to main content
MediaCapture.InitializeAsync(MediaCaptureInitializationSettings) | initializeAsync(MediaCaptureInitializationSettings) method

Initializes the MediaCapture object.

Syntax


mediaCapture.initializeAsync(mediaCaptureInitializationSettings).done( /* Your success and error handlers */ );

public IAsyncAction InitializeAsync(
  MediaCaptureInitializationSettings mediaCaptureInitializationSettings
)

Public Function InitializeAsync(
  mediaCaptureInitializationSettings As MediaCaptureInitializationSettings 
) As IAsyncAction

public:
IAsyncAction^ InitializeAsync(
  MediaCaptureInitializationSettings^ mediaCaptureInitializationSettings
)

Parameters

mediaCaptureInitializationSettings

Type: MediaCaptureInitializationSettings

The initialization settings.

Return value

Type: IAsyncAction

Returns a IAsyncAction object that is used to control the asynchronous operation.

Remarks

InitializeAsync will launch a consent prompt to get the user's permission for the app to access the microphone or camera. InitializeAsync should be called from the main UI thread of your app. For more information, see Guidelines for enabling sensitive devices.

In apps that use C# or C++, the first use of the MediaCapture object to call InitializeAsync should be on the STA thread. Calls from an MTA thread may result in undefined behavior.

Examples

The following example creates a MediaCapture object and calls InitializeAsync to initialize it with MediaCaptureInitializationSettings.


// Create and initialze the MediaCapture object.
function initMediaCapture() {
    oMediaCapture = null;
    oMediaCapture = new Windows.Media.Capture.MediaCapture();
    oMediaCapture.initializeAsync(captureInitSettings).then (function (result) {
       createProfile();
    }, errorHandler);    
}

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Capabilities

webcam
microphone

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

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

Metadata

Windows.winmd

Capabilities

webcam
microphone

See also

MediaCapture
InitializeAsync
Guidelines for enabling sensitive devices