Expand Minimize

MediaElement.NaturalDuration property

Applies to Windows and Windows Phone

Gets the duration of the media file currently opened.


public Duration NaturalDuration { get; }

Property value

Type: Duration

The natural duration of the media. The default value is a Duration structure that evaluates as Automatic, which is the value held if you query this property before MediaOpened.


A Duration value has a TimeSpan component.

  • For Visual C++ component extensions (C++/CX), the data value of a Duration is a property named TimeSpan. This has a TimeSpan structure value, and that structure has a field named Duration that reports the duration as an int64 that counts in 100-nanosecond units. TimeSpan doesn't have any methods for getting components of the time in hours:minutes:seconds format.
  • For C# or Microsoft Visual Basic, you can use utility methods of System.TimeSpan to get the duration components in whatever format you want. For example you can get TimeSpan.Hours, TimeSpan.Minutes and TimeSpan.Seconds separately.
  • For more info, see Remarks in the Duration reference topic.


Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]


Windows::UI::Xaml::Controls [C++]



See also




© 2014 Microsoft