SuperJMN
SuperJMN

Reputation: 13982

Getting the "Media Created" date of a video file in UWP

I want to get the date of creation of a video file, commonly known as Media Created property (not to be confused with the File Creation Date)

I'm trying with this code:

var clip = await MediaClip.CreateFromFileAsync(x);
var encodingProps = clip.GetVideoEncodingProperties();
var props = encodingProps.Properties.ToList();

Inside the props reference I'm getting a list of Guids and values, but I'm lost there.

Upvotes: 2

Views: 1761

Answers (1)

Martin Zikmund
Martin Zikmund

Reputation: 39082

You can use Extended properties to get the specific property you need:

var dateEncodedPropertyName = "System.Media.DateEncoded";
var propertyNames = new List<string>()
{
    dateEncodedPropertyName
};

// Get extended properties
IDictionary<string, object> extraProperties =
    await file.Properties.RetrievePropertiesAsync(propertyNames);

// Get the property value
var propValue = extraProperties[dateEncodedPropertyName];
if (propValue != null)
{
    Debug.WriteLine(propValue);
}

Note I am using the System.Media.DateEncoded property in the example. If you need a different property, check out the full list of supported properties with their exact names in documentation.

Upvotes: 4

Related Questions