IWMPControls::currentPositionString 屬性

[與此頁面相關聯的功能Windows 媒體播放機 SDK是舊版功能。 MediaPlayer已取代它。 MediaPlayer已針對Windows 10和Windows 11進行優化。 Microsoft 強烈建議新程式碼盡可能使用MediaPlayer,而不是Windows 媒體播放機 SDK。 Microsoft 建議使用舊版 API 的現有程式碼盡可能重寫為使用新的 API。

currentPositionString屬性會取得媒體專案中目前的位置,其格式為 HH:MM:SS (小時、分鐘和秒) 。

這個屬性是唯讀的。

Syntax

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#)