我有从 MediaLibrary 返回的 Song 对象。如何获取带有文件名的 uri 或绝对路径?任何未发布的API?构造函数具有用于构造 Song 对象的 FromUri。想知道有没有办法找回来?似乎来自 MediaLibraryExtensions 的 GetPathFromToken。但是我需要想出的“令牌”是什么?谢谢!
问问题
457 次
1 回答
1
回答“我需要拿出什么令牌?” 问题的一部分:
当注册应用程序以扩展 Windows Phone 操作系统的各个部分时,Token 的值被提供给查询字符串上的应用程序,这包括Photo Share Picker、Photo Edit Picker和Auto Launch from a File Association
所有示例都使用GetPictureFromToken,但您可以想象通过文件关联“启动”其他媒体类型的相同场景。
以下是如何将令牌与 GetPicturesFromToken 一起使用的示例
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Get a dictionary of query string keys and values.
IDictionary<string, string> queryStrings = this.NavigationContext.QueryString;
// Ensure that there is at least one key in the query string, and check whether the "token" key is present.
if (queryStrings.ContainsKey("token"))
{
// Retrieve the photo from the media library using the token passed to the app.
MediaLibrary library = new MediaLibrary();
Picture photoFromLibrary = library.GetPictureFromToken(queryStrings["token"]);
// Create a BitmapImage object and add set it as the image control source.
BitmapImage bitmapFromPhoto = new BitmapImage();
bitmapFromPhoto.SetSource(photoFromLibrary.GetImage());
image1.Source = bitmapFromPhoto;
}
}
GetPathFromToken应该以相同的方式运行。
至于问题的其他部分。如果您使用的歌曲对象也通过 MediaLibrary 获得了引用,则无法通过任何合法发布的 api 获取该对象的 uri 或路径。
于 2013-08-05T05:51:37.300 回答