如何在Windows应用商店中导入媒体库?

时间:2014-03-06 07:43:49

标签: c# windows-store-apps winrt-xaml windows-8.1

我制作了一个媒体播放器Windows应用商店应用,我使用filepicker从电脑上播放文件。 但我想导入音乐库和视频库并在主屏幕中显示内容,以便轻松选择要播放的文件。怎么做? 请帮忙..

我正在为我的应用程序使用c#和xaml。

2 个答案:

答案 0 :(得分:1)

为此,您必须使用KnownFolders类。您必须先在应用清单中添加音乐库和视频库功能,然后才能通过该类访问它们。

答案 1 :(得分:0)

这最终对我有用..

IReadOnlyList<Windows.Storage.StorageFile> resultsLibrary; 
// to store the library


resultsLibrary = await Windows.Storage.KnownFolders.MusicLibrary.GetFilesAsync(CommonFileQuery.OrderByName);
// this is the list created.


//and this is what shows the media library in a list in xaml
 length = resultsLibrary.Count;
            list.Items.Clear();


            for (int j = 0; j < length; j++)
            {
                list.Items.Add(resultsLibrary[j].Name);
            }