以前可以使用Albums
Genres
,MediaLibrary
等
using(MediaLibrary library = new MediaLibrary())
{
SongCollection songs = library.Songs;
Song song = songs[0];
MediaPlayer.Play(song);
}
但它在Windows运行时应用程序中不可用。访问这些数据的另一种方法是什么?
这是一款Windows Phone Runtime应用程序。
答案 0 :(得分:2)
使用此
var folder = Windows.Storage.KnownFolders.MusicLibrary;
var files = await folder.GetFilesAsync();
在StorageFile上使用StorageItemContentProperties并致电GetMusicPropertiesAsync,它会返回MusicProperties。
StorageFolder musicFolder = KnownFolders.MusicLibrary;
IReadOnlyList<StorageFile> fileList = await musicFolder.GetFilesAsync();
foreach (var file in fileList)
{
MusicProperties musicProperties = await file.Properties.GetMusicPropertiesAsync();
Debug.WriteLine("Album: " + musicProperties.Album);
Debug.WriteLine("Rating: " + musicProperties.Rating);
Debug.WriteLine("Producers: " + musicProperties.Publisher);
}