0
我想用保存在数据库表中的曲目填充我的后台播放器播放列表。 我如何在Windows Phone 8应用程序中做到这一点?我可以在我的AudioPlayer类中添加数据库查询吗? wp8
我想用保存在数据库表中的曲目填充我的后台播放器播放列表。 我如何在Windows Phone 8应用程序中做到这一点?我可以在我的AudioPlayer类中添加数据库查询吗? wp8
BackgroundAudioPlayer只能播放独立存储或远程URI中的文件。您需要做的就是将音轨列表作为播放器的播放列表。
这些只是根据您的需要修改的示例示例。
//获取uri使用文件的IsolatedStorageFileStream Name属性进行跟踪。 reference
private static string GetAbsolutePath(string filename)
{
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
string absoulutePath = null;
if (isoStore.FileExists(filename))
{
IsolatedStorageFileStream output = new IsolatedStorageFileStream(filename, FileMode.Open, isoStore);
absoulutePath = output.Name;
output.Close();
output = null;
}
return absoulutePath;
}
//now instantiate list of audio track with the uri to track
List<AudioTrack> = new List<AudioTrack>
{
new AudioTrack(new Uri("URI TO FILE IN ISOLATED STORAGE", UriKind.Relative),
"title",
"artist",
"album",
"Uri To albumArt or null"),
new AudioTrack(new Uri("URI TO FILE IN ISOLATED STORAGE", UriKind.Relative),
"title",
"artist",
"album",
"Uri To albumArt or null")
};
对于进一步阅读:http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202978(v=vs.105).aspx