DirectShow Animated Header -- IMediaPosition Object DirectShow Animated Header -- IMediaPosition Object* Microsoft DirectShow SDK
*Index  *Topic Contents
*Previous Topic: IMediaEvent Object
*Next Topic: IMediaTypeInfo Object

IMediaPosition Object


The filter graph exposes the IMediaPosition object if any of the filters within the graph are seekable (can seek to an arbitrary position in the stream). Filters will expose IMediaPosition if they can seek their data or if they connect to an output pin that represents a seekable stream.

Applications that communicate with the filter graph can call methods on this interface to set or retrieve properties such as the stream's duration, the start and stop times, the preroll time, the rate, and the current position. The filter graph uses these properties on seekable filters to control the playback of streams within the graph; where there are multiple streams, the filter graph sets them all to play in parallel, beginning at the same position, and will report the duration as being the duration of the longest stream. The parameters used in this interface are double values representing a fractional number of seconds. Internally, filters will store time to an accuracy of 100 nanoseconds.

Properties
Name Description
CurrentPosition Retrieves or sets the current position in terms of the total length of the media stream.
Duration Retrieves the total duration of the media stream.
PrerollTime Retrieves or sets the time prior to the start position at which nonrandom access devices should start rolling.
Rate Retrieves or sets the playback rate, relative to normal playback of the media stream.
StopTime Retrieves or sets the position within the media stream at which playback should stop.

Methods
Name Description
CanSeekBackward Retrieves whether or not you can seek backward in the current stream.
CanSeekForward Retrieves whether or not you can seek forward in the current stream.


CurrentPosition Property (IMediaPosition Object)

IMediaPosition Object

Retrieves or sets the current position in terms of the total length of the media stream.

objMediaPosition.CurrentPosition [=dblValue]

Parts
objMediaPosition
Object expression that evaluates to an IMediaPosition object.
dblValue
Double value specifying the new current position.
Remarks

The CurrentPosition property represents the position that playback has reached. It is a value between zero and the duration (that is, it has been adjusted for rate and start time). If the graph is paused, this is the position at which it will restart.

This property can also be used to set the start time. When used in this way, the current position indicates a position between zero and the duration of the media at which playback should begin when the Run method is called.

When the filter graph is stopped or paused, this property returns the position at which playback will recommence. When the filter graph is running, the filter graph manager returns the position according to the reference clock. If an individual filter implements this, it should return the stream time of the sample it is currently processing (that is, the offset time from the beginning) when paused or running.

After stopping or pausing, a run command causes playback to begin at the current position. This will be where playback stopped or paused, unless the application changes the CurrentPosition call in the meantime.

If this method is called when the filter graph manager is running, the filter graph manager will pause the graph, run the method, and then issue a new run command.

Setting the current position when paused or stopped causes playback to resume from the new start position when the run command is issued.

The current position is applied before the rate and therefore is the position at typical playback speed.


Duration Property (IMediaPosition Object)

IMediaPosition Object

Retrieves the total duration of the media stream.

objMediaPosition.Duration

Parts
objMediaPosition
Object expression that evaluates to an IMediaPosition object.
Remarks

The duration assumes normal playback speed, and it is therefore unaffected by the rate.


PrerollTime Property (IMediaPosition Object)

IMediaPosition Object

Retrieves or sets the time prior to the start position that devices should start rolling.

objMediaPosition.PrerollTime [=dblValue]

Parts
objMediaPosition
Object expression that evaluates to an IMediaPosition object.
dblValue
Double value for the PrerollTime property.
Remarks

Preroll time is the time prior to the start position at which nonrandom access devices, such as tape players, should start rolling.


Rate Property (IMediaPosition Object)

IMediaPosition Object

Retrieves or sets the playback rate relative to normal playback speed.

objMediaPosition.Rate [= dblValue]

Parts
objMediaPosition
Object expression that evaluates to an IMediaPosition object.
dblValue
New value for the rate. Double.
Remarks

This property allows an application to speed up or slow down playback relative to the normal default playback speed. A rate of 1.0 indicates normal playback speed. Specifying 2.0 causes playback at twice the normal rate: a video created for 10 frames per second (fps) will be played back at 20 fps, if resources permit. Audio streams played back at above-normal speed increase the pitch rather than drop samples. A rate of 0.5 indicates half speed.


StopTime Property (IMediaPosition Object)

IMediaPosition Object

Retrieves or sets the time at which the media stream stops.

objMediaPosition.StopTime [ = dblValue]

Parts
objMediaPosition
Object expression that evaluates to an IMediaPosition object.
dblValue
New value for the stop time.
Remarks

The stop time is a position between zero and the duration of the media at which playback should stop.

The stop position is applied before the rate and therefore is the position at typical playback speed.


CanSeekBackward Method (IMediaPosition Object)

IMediaPosition Object

Retrieves whether or not you can seek backward through the current stream.

objMediaPosition.CanSeekBackward

Parts
objMediaPosition
Object expression that evaluates to an IMediaPosition object.
Remarks

The return value is of type If the value is 0, you cannot seek through the current stream. If the value is –1, you can seek. If you cannot seek through the stream, you can still set the stream's current position with CurrentPosition.

This method can return only –1 (True) with media streams that consist of a single media type, such as a WAV file or video-only MPEG file.


CanSeekForward Method (IMediaPosition Object)

IMediaPosition Object

Retrieves whether or not you can seek forward through the current stream.

objMediaPosition.CanSeekForward

Parts
objMediaPosition
Object expression that evaluates to an IMediaPosition object.
Remarks

The return value is of type If the value is 0, you cannot seek through the current stream. If the value is –1, you can seek. If you cannot seek through the stream, you can still set the stream's current position with CurrentPosition.

This method can return only –1 (True) with media streams that consist of a single media type, such as a WAV file or video-only MPEG file.

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.

*Top of Page