Skip to main content
IMFMediaEngineClassFactory::CreateInstance method

Creates a new instance of the Media Engine.


HRESULT CreateInstance(
  [in]  DWORD          dwFlags,
  [in]  IMFAttributes  *pAttr,
  [out] IMFMediaEngine **ppPlayer


dwFlags [in]

A bitwise OR of zero or more flags from the MF_MEDIA_ENGINE_CREATEFLAGS enumeration.

pAttr [in]

A pointer to the IMFAttributes interface of an attribute store.

This parameter specifies configuration attributes for the Media Engine. Call MFCreateAttributes to create the attribute store. Then, set one or more attributes from the list of Media Engine Attributes. For details, see Remarks.

ppPlayer [out]

Receives a pointer to the IMFMediaEngine interface. The caller must release the interface.

Return value

This method can return one of these values.

Return codeDescription



A required attribute was missing from pAttr, or an invalid combination of attributes was used.



Before calling this method, call MFStartup.

The Media Engine supports three distinct modes:

Frame-server mode

In this mode, the Media Engine delivers uncompressed video frames to the application. The application is responsible for displaying each frame, using Microsoft Direct3D or any other rendering technique.

The Media Engine renders the audio; the application is not responsible for audio rendering.

Frame-server mode is the default mode.

Rendering mode

In this mode, the Media Engine renders both audio and video. The video is rendered to a window or Microsoft DirectComposition visual provided by the application.

To enable rendering mode, set either the MF_MEDIA_ENGINE_PLAYBACK_HWND attribute or the MF_MEDIA_ENGINE_PLAYBACK_VISUAL attribute.

Audio mode

In this mode, the Media Engine renders audio only, with no video.

To enable audio mode, set the MF_MEDIA_ENGINE_AUDIOONLY flag in the dwFlags parameter.


Intialization Attributes

The following attributes are defined for the pAttr parameter. Some are required, and some are optional, depending on the mode you want.

FeatureAttributesFrame Server ModeRendering ModeAudio Mode
Event callback MF_MEDIA_ENGINE_CALLBACK Required.Required.Required.
Render target

One of the following:


These attributes are mutually exclusive. Setting either of these attributes puts the Media Engine into rendering mode.

Do not set.Required. Do not set.
Direct3D format MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT Required.Optional.Do not set.
Microsoft DirectX Graphics Infrastructure (DXGI) device manager MF_MEDIA_ENGINE_DXGI_MANAGER Optional.Optional.Do not set.
Media Engine extensions MF_MEDIA_ENGINE_EXTENSION Optional.Optional.Optional.
Content protection

Any of the following:

Audio playback

Any of the following:



Windows Phone 8

This API is supported.

On the phone, the Media Engine only supports frame-server mode. Attempting to initialize the interface in either rendering mode or audio mode will fail.


Minimum supported client

Windows 8 [desktop apps | UWP apps]

Minimum supported server

Windows Server 2012 [desktop apps | UWP apps]



See also