AxWindowsMediaPlayer.playState 属性

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

playState 属性获取一个枚举值,该值指示Windows 媒体播放器操作的状态。

此属性为只读。

语法

public WMPPlayState playState {get;}

Public ReadOnly Property playState As WMPPlayState

属性值

WMPLib.WMPPlayState 枚举值。

备注

Windows 媒体播放器状态不保证按任何特定顺序发生。 此外,并非每个状态都必然在一系列事件期间发生。 不应编写依赖于状态顺序的代码。

示例

以下示例使用 playState 属性在标签中显示玩家的当前播放状态。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。

// Test whether Windows Media Player is in the playing state. 
if (player.playState == WMPLib.WMPPlayState.wmppsPlaying)
{
    playStateLabel.Text = "Windows Media Player is playing!";
}
else
{
    playStateLabel.Text = "Windows Media Player is NOT playing!";
}

' Test whether Windows Media Player is in the playing state. 
If (player.playState = WMPLib.WMPPlayState.wmppsPlaying) Then

    playStateLabel.Text = "Windows Media Player is playing!"

Else

    playStateLabel.Text = "Windows Media Player is NOT playing!"

End If

要求

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

另请参阅

AxWindowsMediaPlayer 对象 (VB 和 C#)

AxWindowsMediaPlayer.PlayStateChange 事件 (VB 和 C#)

WMPPlayState