Partilhar via


Position

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

value = object.Position
object.Position = value

Property Value

Type: TimeSpan

The amount of time since the beginning of the media.

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

Managed Equivalent

Position

Remarks

The string format for specifying a TimeSpan object is [days.]hours:minutes:seconds[.fractionalSeconds]. Creating a TimeSpan in XAML is possible only through a type conversion syntax, when you set 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 the Position property to set a specific position within the media. There is no 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 value of CanSeek before attempting to set Position.

If the Position can be set, but it is set either to a negative value or to a value that is 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 there is no guarantee that the media can be positioned until the media source is loaded. After MediaOpened is raised, check the value of CanSeek. If it is true, the media can be positioned, and you can set Position in scripting.

Applies To

MediaElement