IMFPMediaPlayer::SetRate method (mfplay.h)
[The feature associated with this page, MFPlay, is a legacy feature. It has been superseded by MediaPlayer and IMFMediaEngine. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer and IMFMediaEngine instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
Sets the playback rate.
Syntax
HRESULT SetRate(
[in] float flRate
);
Parameters
[in] flRate
Playback rate. The playback rate is expressed as a ratio of the current rate to the normal rate. For example, 1.0 indicates normal playback speed, 0.5 indicates half speed, and 2.0 indicates twice speed. Positive values indicate forward playback, and negative values indicate reverse playback.
Return value
The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.
Return code | Description |
---|---|
|
The method succeeded. |
|
The flRate parameter is zero. |
|
The object's Shutdown method was called. |
Remarks
This method completes asynchronously. When the operation completes, the application's IMFPMediaPlayerCallback::OnMediaPlayerEvent callback method is invoked. The event type is MFP_EVENT_TYPE_RATE_SET.
The method sets the nearest supported rate, which will depend on the underlying media source. For example, if flRate is 50 and the source's maximum rate is 8× normal rate, the method will set the rate to 8.0. The actual rate is indicated in the event data for the MFP_EVENT_TYPE_RATE_SET event.
To find the range of supported rates, call IMFPMediaPlayer::GetSupportedRates.
This method does not support playback rates of zero, although Media Foundation defines a meaning for zero rates in some other contexts.
The new rate applies only to the current media item. Setting a new media item resets the playback rate to 1.0.
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 |