Share via


Windows Media Player 11 SDK IWMPSettings.rate (VB and C#) 

Windows Media Player SDK banner art

Previous Next

IWMPSettings.rate (VB and C#)

The rate property gets or sets the current playback rate for video.

  

Property Value

A System.Double that is the playback rate, with a default value of 1.0.

Remarks

The value retrieved by this property acts as a multiplier value that enables you to play a media item at a faster or slower rate. The default value of 1.0 indicates the authored speed.

Note that an audio track becomes difficult to understand at rates lower than 0.5 or higher than 1.5. A playback rate of 2 indicates twice the normal playback speed.

Windows Media Player will attempt to use the most effective of the following four different playback modes

  • Smooth video playback with audio pitch maintained
  • Smooth video playback with audio pitch not maintained
  • Smooth video playback with no audio
  • Keyframe video playback with no audio

The mode chosen by Windows Media Player depends on numerous factors including file type and location, operating system, network, and server.

Other considerations apply as well, depending on the digital media format used to create the content:

  • Windows Media Video (WMV) and ASF. Optimal values for the rate property are from 1 to 10, or from –1 to –10 for reverse play. Values from 0.5 to 1.0 or from -0.5 to -1.0 may also work well in cases where audio pitch can be maintained, such as when playing files located on the local computer. Values with an absolute magnitude greater than 10 are allowed, but are not very meaningful.
  • Other video formats. The rate property can range from 0 to 9. Negative values are not allowed. Values less than 1 represent slow motion. Values above 9 are allowed, but are not very meaningful.

The IWMPControls.fastForward method changes the value of rate to 5.0, while the IWMPControls.fastReverse method changes the value of rate to –5.0.

The playback rate of some digital media formats cannot be altered. Use the IWMPSettings.isAvailable property (In C# the IWMPSettings.get_isAvailable method) to discover whether this property can be specified for a particular media item.

Example Code

The following example uses a numeric updown control that allows the user to change the playback speed of the current media. When the user clicks the up or down arrows of the control, the rate property is set to the new value. The possible range of values in the control are 0.5 (half-speed) to 2.0 (double-speed). The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

  
Public Sub playbackRate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles playbackRate.Click

    '  Get the new value of the control as a double.
    Dim nUpDown As System.Windows.Forms.NumericUpDown = sender
    Dim newRate As Double = nUpDown.Value

    '  Test whether playback rate can be set. 
    If (player.settings.isAvailable("Rate")) Then

        '  Set the playback rate to the new value.
        player.settings.rate = newRate

    End If

End Sub

FakePre-bb820ae72c464ae1bb756750e67fc1bc-94d4c015e0284d6ba006cef4d3b920b2

private void playbackRate_Click(object sender, System.EventArgs e)
{
    // Get the new value of the control, and cast it from decimal to double.
    double newRate = (double)((System.Windows.Forms.NumericUpDown)sender).Value;

    // Test whether playback rate can be set. 
    if( player.settings.get_isAvailable("Rate") )
    {
        // Set the playback rate to the new value.
        player.settings.rate = newRate;
    }
}

Requirements

Version: Windows Media Player 9 Series or later

Namespace: WMPLib

Assembly: Interop.WMPLib.dll (automatically generated by Visual Studio)

See Also

Previous Next