IWMPControls::p lay 方法

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

play 方法开始播放当前媒体项,或继续播放暂停的项。

语法

public void play();

Public Sub play()
Implements IWMPControls.play

参数

此方法没有任何参数。

返回值

此方法不返回值。

备注

如果在快进或倒退时调用此方法,则播放速率 (IWMPSettings.rate) 的值设置为 1.0。

示例

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

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

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

        controls.play()

    End If

End Sub

要求

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

另请参阅

IWMPControls 接口 (VB 和 C#)

IWMPControls.playItem (VB 和 C#)

IWMPSettings.rate (VB 和 C#)