IWMPControls::p ause 方法

[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]

暂停方法暂停媒体项的播放。

语法

public void pause();

Public Sub pause()
Implements IWMPControls.pause

参数

此方法没有任何参数。

返回值

此方法不返回值。

备注

暂停文件时,Windows 媒体播放器不会放弃任何系统资源,例如音频设备。

若要确定是否可以暂停特定媒体类型,请将 System.String 值“pause”传递给 C#) IWMPControls.get_isAvailable 方法 (IWMPControls.isAvailable 属性。

示例

以下示例使用 暂停 暂停播放当前媒体项,以响应按钮的 Click 事件。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。

private void pauseButton_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("pause"))
    {
        controls.pause();
    }
}

Public Sub pauseButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles pauseButton.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("pause")) Then

        controls.pause()

    End If

End Sub

要求

要求
版本
Windows 媒体播放器 9 系列或更高版本
命名空间
WMPLib
程序集
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

另请参阅

IWMPControls 接口 (VB 和 C#)

IWMPControls.isAvailable (VB 和 C#)