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 |
組件 |
|
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應