IMFPMediaPlayer::GetPosition method (mfplay.h)
Gets the current playback position.
Syntax
HRESULT GetPosition(
[in] REFGUID guidPositionType,
[out] PROPVARIANT *pvPositionValue
);
Parameters
[in] guidPositionType
Specifies the unit of time for the playback position. The following value is defined.
Value | Meaning |
---|---|
|
100-nanosecond units.
The value returned in pvPositionValue is a LARGE_INTEGER.
|
[out] pvPositionValue
Pointer to a PROPVARIANT that receives the playback position.
Return value
The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.
Return code | Description |
---|---|
|
The method succeeded. |
|
Invalid argument. |
|
No media item has been queued. |
|
The object's Shutdown method was called. |
Remarks
The playback position is calculated relative to the start time of the media item, which can be specified by calling IMFPMediaItem::SetStartStopPosition. For example, if you set the start time to 20 seconds and the source duration is 60 seconds, the range of values returned by GetPosition is 0–40 seconds.
Examples
The following code gets the current position, in 100-nanosecond units, as a LONGLONG value.
HRESULT GetPositionHNS(
IMFPMediaPlayer *pPlayer,
LONGLONG *phnsPosition // Receives the position in hns.
)
{
HRESULT hr = S_OK;
PROPVARIANT var;
PropVariantInit(&var);
*phnsPosition = 0;
hr = pPlayer->GetPosition(MFP_POSITIONTYPE_100NS, &var);
if (SUCCEEDED(hr))
{
*phnsPosition = var.hVal.QuadPart;
}
PropVariantClear(&var);
return hr;
}
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
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for