简体   繁体   中英

uwp StorageFile adding a custom property

In my uwp app I am getting Video files with KnownFolders.VideoLibrary . I am able to PreFetch videoProperties of the file and also some other properties. Now I actually want to tag the video files with some string data, and save that data so I can check that later on.

For example I want to add them to Liked Videos so can I add a custom property on the storagefile which will remain saved every time I run the app. This will let me check whether a specific storagefile is liked or not.

Currently I know I can edit and save videoproperties like following.

var vp = await file.Properties.GetVideoPropertiesAsync();
vp.Title="Liked";
vp.Properties.SavePropertiesAsync();

but the problem is these properties won't be empty by default. I want a property which will be empty be default for all StorageFiles so that I can check whether they are empty or marked as Liked .

I also intend to save the token which I will get from FutureAccessList for that file. I know I can create a database table and do all of this there, but that can create other complications hence I want to keep it simple.

There are many properties in the video file. And the official documentation does not specify that they are empty by default. However, the video property has Keywords list property, you could add Liked keywords to the list like follow.

VideoProperties videoProperties = await file.Properties.GetVideoPropertiesAsync();
videoProperties.Keywords.Add("Liked");
await videoProperties.SavePropertiesAsync();

Although you could add the some info to keywords list, it is still very limited. So the best practices to achieve this feature is to create a database table to record info. And you could also set a Comment property use DocumentProperties.Comment , for more you could refer this case .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM