IMediaSeeking::SetPositions method

The SetPositions method sets the current position and the stop position.


HRESULT SetPositions(
  [in, out] LONGLONG *pCurrent,
  [in]      DWORD    dwCurrentFlags,
  [in, out] LONGLONG *pStop,
  [in]      DWORD    dwStopFlags


pCurrent [in, out]

[in,out] Pointer to a variable that specifies the current position, in units of the current time format.

dwCurrentFlags [in]

Bitwise combination of flags. See Remarks.

pStop [in, out]

[in,out] Pointer to a variable that specifies the stop time, in units of the current time format.

dwStopFlags [in]

Bitwise combination of flags. See Remarks.

Return value

Returns an HRESULT value. Possible values include the following.

Return codeDescription

No position change. (Both flags specify no seeking.)




Invalid argument.


Method is not supported.


NULL pointer argument.



The dwCurrentFlags and dwStopFlags parameters define the type of seek. The following flags are defined.

Positioning Flags Description
AM_SEEKING_NoPositioningNo change in position. (The time parameter can be NULL.)
AM_SEEKING_AbsolutePositioningThe specified position is absolute.
AM_SEEKING_RelativePositioningThe specified position is relative to the previous value.
AM_SEEKING_IncrementalPositioningThe stop position (pStop) is relative to the current position (pCurrent).


Modifier Flags Description
AM_SEEKING_SeekToKeyFrameSeek to the nearest key frame. This might be faster, but less accurate. None of the filters that ship with DirectShow support this flag. Decoders are the most likely type of filter to support it.
AM_SEEKING_ReturnTimeReturn the equivalent reference times.
AM_SEEKING_SegmentUse segment seeking.
AM_SEEKING_NoFlushDo not flush.


For each parameter, use one positioning flag. Optionally, include one or more modifier flags.

If the AM_SEEKING_ReturnTime flag is specified, the method converts the position value to a reference time and returns it in the pCurrent or pStop variable. This flag is useful if you are using another time format, such as frames.

The AM_SEEKING_Segment and AM_SEEKING_NoFlush flags support seamless looping:

  • If the AM_SEEKING_Segment flag is present, the source filter sends an EC_END_OF_SEGMENT event when it reaches the stop position, instead of calling IPin::EndOfStream. The application can wait for this event and then issue another seek command.
  • If the AM_SEEKING_NoFlush flag is present, the graph does not flush data during the seek. Use this flag with AM_SEEKING_Segment.

To perform looping, the graph must report AM_SEEKING_CanDoSegments in the IMediaSeeking::GetCapabilities method. Currently, only the WAVE Parser Filter supports this feature.

The incoming values of pCurrent and pStop are expressed in the current time format. The default time format is REFERENCE_TIME units (100 nanoseconds). To change time formats, use the IMediaSeeking::SetTimeFormat method. If the AM_SEEKING_ReturnTime flag is present, the method converts the outgoing value to REFERENCE_TIME units.

Filter Developers

If you implement this method, you can check whether the caller is requesting a change in the current or stop position, by using the value AM_SEEKING_PositioningBitsMask to mask out the modifier flags. For example:

DWORD dwCurrentPos = dwCurrentFlags & AM_SEEKING_PositioningBitsMask
if (dwCurrentPos == AM_SEEKING_AbsolutePositioning)
    // Set new position to pCurrent.
    m_rtStart = *pCurrent;
else if (dwCurrentPos == AM_SEEKING_RelativePositioning)
    // Increment current position by pCurrent.
    m_rtStart += *pCurrent;

For more information, see the source code for the CSourceSeeking::SetPositions method in the base class library.


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]


Strmif.h (include Dshow.h)



See also

Error and Success Codes
IMediaSeeking Interface