مشاركة عبر


MediaElement.NaturalDuration Property

Definition

Gets the duration of the media file currently opened.

Duration NaturalDuration();
public Duration NaturalDuration { get; }
var duration = mediaElement.naturalDuration;
Public ReadOnly Property NaturalDuration As Duration

Property Value

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.

Remarks

A Duration value has a TimeSpan component.

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.

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 more info, see Remarks in the Duration reference topic.

Applies to