Export (0) Print
Expand All

IMFPMediaItem::GetDuration method

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

guidPositionType [in]

Specifies the unit of time for the duration value. The following value is defined.

ValueMeaning
MFP_POSITIONTYPE_100NS

100-nanosecond units.

The value returned in pvDurationValue is a LARGE_INTEGER.

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

 

pvDurationValue [out]

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]

Header

Mfplay.h

See also

How to Get the Playback Duration
Using MFPlay for Audio/Video Playback
IMFPMediaItem

 

 

Community Additions

ADD
Show:
© 2014 Microsoft