Dela via


MediaCapture.InitializeAsync Method

Definition

Overloads

InitializeAsync()

Initializes the MediaCapture object, using default settings.

InitializeAsync(MediaCaptureInitializationSettings)

Initializes the MediaCapture object.

InitializeAsync()

Initializes the MediaCapture object, using default settings.

public:
 virtual IAsyncAction ^ InitializeAsync() = InitializeAsync;
/// [Windows.Foundation.Metadata.Overload("InitializeAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction InitializeAsync();
[Windows.Foundation.Metadata.Overload("InitializeAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction InitializeAsync();
function initializeAsync()
Public Function InitializeAsync () As IAsyncAction

Returns

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

Attributes

Windows requirements

App capabilities
backgroundMediaRecording microphone webcam

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

For how-to guidance on initializing and shutting down the MediaCapture object, see Basic photo, video, and audio capture with MediaCapture.

Starting with Windows, version 1803, InitializeAsync will return an error or throw an exception with an error code of 0xC00DAFC8 (MF_E_UNSUPPORTED_CAPTURE_DEVICE_PRESENT) when an unsupported capture device is detected. You can check for this error code and update your UI to alert to the user.

See also

Applies to

InitializeAsync(MediaCaptureInitializationSettings)

Initializes the MediaCapture object.

public:
 virtual IAsyncAction ^ InitializeAsync(MediaCaptureInitializationSettings ^ mediaCaptureInitializationSettings) = InitializeAsync;
/// [Windows.Foundation.Metadata.Overload("InitializeWithSettingsAsync")]
IAsyncAction InitializeAsync(MediaCaptureInitializationSettings const& mediaCaptureInitializationSettings);
[Windows.Foundation.Metadata.Overload("InitializeWithSettingsAsync")]
public IAsyncAction InitializeAsync(MediaCaptureInitializationSettings mediaCaptureInitializationSettings);
function initializeAsync(mediaCaptureInitializationSettings)
Public Function InitializeAsync (mediaCaptureInitializationSettings As MediaCaptureInitializationSettings) As IAsyncAction

Parameters

mediaCaptureInitializationSettings
MediaCaptureInitializationSettings

The initialization settings.

Returns

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

Attributes

Windows requirements

App capabilities
backgroundMediaRecording microphone webcam

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

For how-to guidance on initializing and shutting down the MediaCapture object, see Basic photo, video, and audio capture with MediaCapture.

Starting with Windows, version 1803, InitializeAsync will return an error or throw an exception with an error code of 0xC00DAFC8 (MF_E_UNSUPPORTED_CAPTURE_DEVICE_PRESENT) when an unsupported capture device is detected. You can check for this error code and update your UI to alert to the user.

See also

Applies to