IMFPMediaItem::GetDuration 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 duration of the media item.
Syntax
HRESULT GetDuration(
[in] REFGUID guidPositionType,
[out] PROPVARIANT *pvDurationValue
);
Parameters
[in] guidPositionType
Specifies the unit of time for the duration value. The following value is defined.
| Value | Meaning |
|---|---|
|
100-nanosecond units.
The value returned in pvDurationValue is a LARGE_INTEGER.
|
[out] pvDurationValue
Pointer to a PROPVARIANT that receives the duration.
Return value
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
The method returns the total duration of the content, regardless of any values set through IMFPMediaItem::SetStartStopPosition.
Examples
#include <propvarutil.h>
HRESULT GetPlaybackDuration(IMFPMediaItem *pItem, ULONGLONG *phnsDuration)
{
PROPVARIANT var;
HRESULT hr = pItem->GetDuration(MFP_POSITIONTYPE_100NS, &var);
if (SUCCEEDED(hr))
{
hr = PropVariantToUInt64(var, phnsDuration);
PropVariantClear(&var);
}
return hr;
}
Requirements
| Minimum supported client | Windows 7 [desktop apps only] |
| Minimum supported server | Windows Server 2008 R2 [desktop apps only] |
| Target Platform | Windows |
| Header | mfplay.h |