IWMPControls::currentPositionString 属性

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

currentPositionString 属性获取媒体项中的当前位置,该字符串格式为 HH:MM:SS (小时、分钟和秒) 。

此属性为只读。

语法

public System.String currentPositionString {get;}

Public ReadOnly Property currentPositionString As System.String

属性值

作为当前位置的带格式 的 System.String

备注

如果媒体项的长度小于一小时,则当前位置的格式设置为 MM:SS (分和秒) 。

示例

以下示例启动一个计时器,该计时器每隔一秒触发一次事件。 在计时器事件处理程序中,使用 currentPositionString 更新标签。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。

// Set the timer to fire an event every second and start the timer.
timer.Interval = 1000;
timer.Start();

// Note:  Use the AxWindowsMediaPlayer.PlayStateChange event with a switch statement to
// determine when to start and stop the timer. 
   
// Update the text of the label with the currentPositionString.
private void TimerEventProcessor(object sender, System.EventArgs e)
{
    currentPositionLabel.Text = player.Ctlcontrols.currentPositionString;
}

' Set the timer to fire an event every second and start the timer.
timer.Interval = 1000
timer.Start()

' Note:  Use the AxWindowsMediaPlayer.PlayStateChange event with a switch statement to
' determine when to start and stop the timer. 

' Update the text of the label with the currentPositionString.
Public Sub TimerEventProcessor(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer.Tick

    currentPositionLabel.Text = player.Ctlcontrols.currentPositionString

End Sub

要求

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

另请参阅

IWMPControls 接口 (VB 和 C#)

IWMPControls.currentPosition (VB 和 C#)