Share via


IWMPControls::stop method

[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The stop method stops playback of the media item.

Syntax

public void stop();

Public Sub stop()
Implements IWMPControls.stop

Parameters

This method has no parameters.

Return value

This method does not return a value.

Remarks

This method causes Windows Media Player to release any system resources it is using, such as the audio device. The current media item, however, is not released.

When Windows Media Player is stopped, the current playback position in the media item is reset to the beginning of the item. Subsequently calling IWMPControls.play will start playback from the beginning of the media item. To halt a play operation without changing the current position, use the IWMPControls.pause method.

Examples

The following example uses stop to stop the current media item in response to the Click event of a button. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

private void stopButton_Click(object o, System.EventArgs args)
{
    // To get all of the available functionality of the player controls, cast the
    // value returned by player.Ctlcontrols to a WMPLib.IWMPControls3 interface. 
    WMPLib.IWMPControls3 controls = (WMPLib.IWMPControls3)player.Ctlcontrols;

    // Check first to be sure the operation is valid. 
    if (controls.get_isAvailable("stop"))
    {
        controls.stop();
    }
}

Public Sub stopButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles stopButton.Click

    ' To get all of the available functionality of the player controls, Dim the
    ' value returned by player.Ctlcontrols as a WMPLib.IWMPControls3 interface.
    Dim controls As WMPLib.IWMPControls3 = player.Ctlcontrols

    ' Check first to be sure the operation is valid. 
    If (controls.isAvailable("stop")) Then

        controls.stop()

    End If

End Sub

Requirements

Requirement Value
Version
Windows Media Player 9 Series or later
Namespace
WMPLib
Assembly
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

See also

IWMPControls Interface (VB and C#)

IWMPControls.next (VB and C#)

IWMPControls.pause (VB and C#)

IWMPControls.play (VB and C#)

IWMPControls.previous (VB and C#)