Export (0) Print
Expand All
Expand Minimize

MFPCreateMediaPlayer function

Important  Deprecated. This API may be removed from future releases of Windows. Applications should use the Media Session for playback.

Creates a new instance of the MFPlay player object.

Syntax


HRESULT MFPCreateMediaPlayer(
  _In_   LPCWSTR pwszURL,
  _In_   BOOL fStartPlayback,
  _In_   MFP_CREATION_OPTIONS creationOptions,
  _In_   IMFPMediaPlayerCallback *pCallback,
  _In_   HWND hWnd,
  _Out_  IMFPMediaPlayer **ppMediaPlayer
);

Parameters

pwszURL [in]

Null-terminated string that contains the URL of a media file to open. This parameter can be NULL. If the parameter is NULL, fStartPlayback must be FALSE.

If this parameter is NULL, you can open a URL later by calling IMFPMediaPlayer::CreateMediaItemFromURL.

fStartPlayback [in]

If TRUE, playback starts automatically. If FALSE, playback does not start until the application calls IMFMediaPlayer::Play.

If pwszURL is NULL, this parameter is ignored.

creationOptions [in]

Bitwise OR of zero of more flags from the _MFP_CREATION_OPTIONS enumeration.

pCallback [in]

Pointer to the IMFPMediaPlayerCallback interface of a callback object, implemented by the application. Use this interface to get event notifications from the MFPlay player object. This parameter can be NULL. If the parameter is NULL, the application will not receive event notifications from the player object.

hWnd [in]

A handle to a window where the video will appear. For audio-only playback, this parameter can be NULL.

The window specified by hWnd is used for the first selected video stream in the source. If the source has multiple video streams, you must call IMFPMediaItem::SetStreamSink to render any of the video streams after the first.

If hWnd is NULL, MFPlay will not display any video unless the application calls IMFPMediaItem::SetStreamSink to specify a media sink for the video stream.

ppMediaPlayer [out]

Receives a pointer to the IMFPMediaPlayer interface. The caller must release the interface. This parameter can be NULL. If this parameter is NULL, fStartPlayback must be TRUE and pwszURL cannot be NULL.

Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Before calling this function, call CoIntialize(Ex) from the same thread to initialize the COM library.

Internally, MFPCreateMediaPlayer calls MFStartup to initialize the Microsoft Media Foundation platform. When the player object is destroyed, it calls MFShutdown to shut down the platform. It is not necessary for an application to call MFStartup or MFShutdown when using MFPlay.

Note  If you use other Media Foundation APIs outside the life time of the player object, then your application should call MFStartup and MFShutdown.

Requirements

Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 [desktop apps only]

Header

Mfplay.h

Library

Mfplay.lib

DLL

Mfplay.dll

See also

Media Foundation Functions
Using MFPlay for Audio/Video Playback

 

 

Community Additions

ADD
Show:
© 2014 Microsoft