在 UWP 中获取视频文件的 "Media Created" 日期

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

我想获取视频文件的创建日期,通常称为 Media Created 属性(不要与 文件创建日期)

我正在尝试使用此代码:

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

props 参考中,我得到了一个 Guid 和值的列表,但我在那里迷路了。

您可以使用 Extended properties 获取您需要的特定 属性:

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);
}

注意我使用的是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