Position Property

Gets or sets the current progress through the media's playback time.

XAML
See Remarks.
Scripting
value = object.Position
object.Position = value

Property Value

TimeSpan

The amount of time since the beginning of the media.

This property is read/write. The default value is a TimeSpan with value 00:00:00.

Remarks

The string format for specifying a TimeSpan is [days.]hours:minutes:seconds[.fractionalSeconds]. See TimeSpan. Creating a TimeSpan in XAML is only possible through a type conversion syntax when setting a property such as Position that takes a TimeSpan as an attribute string. Creating a TimeSpan in script also uses the type conversion syntax by setting Position with a properly formatted string.

Use this property to set to a specific position within the media. This property is settable, rather than there being a specific "MediaElement.Seek" method.

The maximum value is the NaturalDuration of the media.

If the media does not support seek operations (which is the case for live streaming media), setting this property will have no effect on media playback. Check the the value of CanSeek before attempting to set Position.

If the Position is settable but the Position value is either set to a negative value or is set to a value larger than the media's NaturalDuration, the property value will be set to 00:00:00 or NaturalDuration, respectively.

You generally should not set this value in XAML, because until the media source is loaded there is no guarantee that the media is positionable. After MediaOpened is raised, check the value of CanSeek. If it is true, then the media is positionable, and then you can set Position in scripting.

Applies To

MediaElement

See Also

Media Overview
Supported Media Formats and Protocols