IWMPControls::currentPosition 属性

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

currentPosition 属性获取或设置媒体项中当前位置(以秒为单位)。

语法

public System.Double currentPosition {get; set;}

Public Property currentPosition As System.Double

属性值

作为当前位置的 System.Double

示例

以下示例使用 currentPosition 查找用户提供的位置。 为了响应按钮单击, currentPosition 设置为在名为 newPosition 的文本框中输入的值。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。

private void setPosition_Click(object sender, System.EventArgs e)
{ 
    // ...Add code to ensure that the text box contains a valid value.
 
    // Set the current position of the media item to the position entered by the user.
    player.Ctlcontrols.currentPosition = Convert.ToDouble(newPosition.Text);
}

Public Sub setPosition_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles setPosition.Click

    ' ...Add code to ensure that the text box contains a valid value.

    ' Set the current position of the media item to the position entered by the user.
    player.Ctlcontrols.currentPosition = Convert.ToDouble(newPosition.Text)

End Sub

要求

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

另请参阅

IWMPControls 接口 (VB 和 C#)

IWMPControls.currentPositionString (VB 和 C#)