IMFPMediaPlayer::GetPosition method (mfplay.h)

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

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
MFP_POSITIONTYPE_100NS
100-nanosecond units.

The value returned in pvPositionValue is a LARGE_INTEGER.

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

[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
S_OK
The method succeeded.
E_INVALIDARG
Invalid argument.
MF_E_INVALIDREQUEST
No media item has been queued.
MF_E_SHUTDOWN
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

IMFPMediaPlayer

Using MFPlay for Audio/Video Playback