Windows phone 8 WP:请解释GetPathFromToken中的令牌是什么
MediaLibraryExtensions.GetPathFromToken有2个参数(MediaLibrary库、字符串标记)作为输入。我假设API从媒体库返回指定媒体项的路径,令牌与感兴趣的媒体相关联。然而,我如何找到媒体的“标记”,比如媒体库中的音乐文件?请告诉我如何从给定的歌曲中找出“标记”好吗?提前感谢。当应用程序注册以扩展Windows Phone操作系统的各个部分时,令牌的值将以查询字符串的形式提供给该应用程序,包括和 所有示例都使用,但您可以想象通过文件关联“启动”其他媒体类型的相同场景 下面是如何将令牌与GetPicturesFromToken一起使用的示例Windows phone 8 WP:请解释GetPathFromToken中的令牌是什么,windows-phone-8,token,media-library,Windows Phone 8,Token,Media Library,MediaLibraryExtensions.GetPathFromToken有2个参数(MediaLibrary库、字符串标记)作为输入。我假设API从媒体库返回指定媒体项的路径,令牌与感兴趣的媒体相关联。然而,我如何找到媒体的“标记”,比如媒体库中的音乐文件?请告诉我如何从给定的歌曲中找出“标记”好吗?提前感谢。当应用程序注册以扩展Windows Phone操作系统的各个部分时,令牌的值将以查询字符串的形式提供给该应用程序,包括和 所有示例都使用,但您可以想象通过文件关联“启动”其他媒体类型
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;
}
}
受保护的覆盖无效OnNavigatedTo(NavigationEventArgs e)
{
//获取查询字符串键和值的字典。
IDictionary QueryString=this.NavigationContext.QueryString;
//确保查询字符串中至少有一个键,并检查“令牌”键是否存在。
if(queryStrings.ContainsKey(“令牌”))
{
//使用传递给应用程序的令牌从媒体库检索照片。
MediaLibrary=新的MediaLibrary();
Picture photoFromLibrary=library.GetPictureFromToken(queryString[“token”]);
//创建BitmapImage对象并添加并将其设置为图像控制源。
BitmapImage bitmapFromPhoto=新的BitmapImage();
bitmapFromPhoto.SetSource(photoFromLibrary.GetImage());
image1.Source=bitmapFromPhoto;
}
}
应该以同样的方式行事 当应用程序注册以扩展Windows Phone操作系统的各个部分时,令牌的值以查询字符串的形式提供给该应用程序,这包括,和 所有示例都使用,但您可以想象通过文件关联“启动”其他媒体类型的相同场景 下面是如何将令牌与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;
}
}
受保护的覆盖无效OnNavigatedTo(NavigationEventArgs e)
{
//获取查询字符串键和值的字典。
IDictionary QueryString=this.NavigationContext.QueryString;
//确保查询字符串中至少有一个键,并检查“令牌”键是否存在。
if(queryStrings.ContainsKey(“令牌”))
{
//使用传递给应用程序的令牌从媒体库检索照片。
MediaLibrary=新的MediaLibrary();
Picture photoFromLibrary=library.GetPictureFromToken(queryString[“token”]);
//创建BitmapImage对象并添加并将其设置为图像控制源。
BitmapImage bitmapFromPhoto=新的BitmapImage();
bitmapFromPhoto.SetSource(photoFromLibrary.GetImage());
image1.Source=bitmapFromPhoto;
}
}
应该以同样的方式行事 谢谢。例如,我拍了几张照片。系统会为每张照片分配不同的令牌吗?如何确定哪些令牌与哪张照片关联?这个令牌看起来像是物理URI的绝对路径吗?@thsieh检查我链接的照片共享选择器或照片编辑选择器示例,它们显示了如何注册扩展以便操作系统可以导航到你的应用程序,以及在操作系统导航到你的应用程序后如何从查询字符串访问令牌。对于照片,此标记来自OnNavigatedTo(NavigationEventArgs e)中查询字符串的“FileId”部分,谢谢。例如,我拍了几张照片。系统会为每张照片分配不同的令牌吗?如何确定哪些令牌与哪张照片关联?这个令牌看起来像是物理URI的绝对路径吗?@thsieh检查我链接的照片共享选择器或照片编辑选择器示例,它们显示了如何注册扩展以便操作系统可以导航到你的应用程序,以及在操作系统导航到你的应用程序后如何从查询字符串访问令牌。对于照片,此标记来自OnNavigatedTo(NavigationEventArgs e)中查询字符串的“FileId”部分