IWMPControls::currentPositionString property

[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The currentPositionString property gets the current position in the media item as a string formatted as HH:MM:SS (hours, minutes, and seconds).

This property is read-only.

Syntax

public System.String currentPositionString {get;}

Public ReadOnly Property currentPositionString As System.String

Property value

A formatted System.String that is the current position.

Remarks

If the media item is less than an hour long, the current position is formatted as MM:SS (minutes and seconds).

Examples

The following example starts a timer that triggers an event at one-second intervals. In the timer event handler, a label is updated with the currentPositionString. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named 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

Requirements

Requirement Value
Version
Windows Media Player 9 Series or later
Namespace
WMPLib
Assembly
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

See also

IWMPControls Interface (VB and C#)

IWMPControls.currentPosition (VB and C#)