IMFPMediaPlayer::SetPosition method (mfplay.h)

[The feature associated with this page, MFPlay, is a legacy feature. It has been superseded by MediaPlayer and IMFMediaEngine. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer and IMFMediaEngine instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

Sets the playback position.

Syntax

HRESULT SetPosition(
  [in] REFGUID           guidPositionType,
  [in] const PROPVARIANT *pvPositionValue
);

Parameters

[in] guidPositionType

Unit of time for the playback position. The following value is defined.

Value Meaning
MFP_POSITIONTYPE_100NS
100-nanosecond units.

The value of pvPositionValue must be a LARGE_INTEGER.

  • Variant type (vt): VT_I8
  • Variant member: hVal

[in] pvPositionValue

New playback position. The meaning and data type of this parameter are indicated by the guidPositionType parameter.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code Description
S_OK
The method succeeded.
E_INVALIDARG
Invalid argument.
HRESULT_FROM_WIN32( ERROR_SEEK )
The value of pvPositionValue is not valid.
MF_E_INVALIDREQUEST
No media item has been queued.
MF_E_SHUTDOWN
The object's Shutdown method was called.

Remarks

If you call this method while playback is stopped, the new position takes effect after playback resumes.

This method completes asynchronously. When the operation completes, the application's IMFPMediaPlayerCallback::OnMediaPlayerEvent callback method is invoked. The event type is MFP_EVENT_TYPE_POSITION_SET.

If playback was started before SetPosition is called, playback resumes at the new position. If playback was paused, the video is refreshed to display the current frame at the new position.

If you make two consecutive calls to SetPosition with guidPositionType equal to MFP_POSITIONTYPE_100NS, and the second call is made before the first call has completed, the second call supersedes the first. The status code for the superseded call is set to S_FALSE in the event data for that call. This behavior prevents excessive latency from repeated calls to SetPosition, as each call may force the media source to perform a relatively lengthy seek operation.

Requirements

Requirement Value
Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header mfplay.h

See also

IMFPMediaPlayer

Using MFPlay for Audio/Video Playback