MediaLibraryExtensions.GetPathFromToken에는 입력으로 2 개의 매개 변수 (MediaLibrary 라이브러리, 문자열 토큰)가 있습니다. API가 미디어 라이브러리에서 지정된 미디어 항목의 경로를 반환한다고 가정합니다. 토큰은 관심있는 미디어와 연결되어 있습니다. 그러나 미디어 라이브러리의 음악 파일을 예로 들면 어떻게 미디어의 "토큰"을 찾을 수 있습니까? 주어진 노래에서 "토큰"을 알아내는 방법을 보여 주실 수 있습니까? 미리 감사드립니다.WP : GetPathFromToken에 어떤 토큰이 있는지 설명해주십시오.
1
A
답변
1
토큰의 값은 애플리케이션이 Photo Share Picker, Photo Edit Picker 모든 예 GetPictureFromToken를 사용 Auto Launch from a File Association
포함 윈도우 전화 OS의 다양한 부분을 연장 등록되지만, 쿼리 스트링상의 애플리케이션에 공급 당신은 다른 미디어 유형이 파일 연결을 통해 '개시'되는 것과 동일한 시나리오를 상상할 수 있습니다.
여기에 같은 방식으로 행동해야 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와 토큰을 사용하는 방법의 샘플입니다.
감사합니다. 예를 들어, 몇 장의 사진을 찍었습니다. 시스템별로 각 사진에 다른 토큰이 지정됩니까? 어떤 토큰이 어떤 사진과 연관되어 있는지 어떻게 알 수 있습니까? 이 토큰은 실제 URI에 대한 절대 경로처럼 보입니까? – thsieh
@thsieh 내가 링크 된 사진 공유 선택기 또는 사진 편집 선택기 예제를 확인하십시오. OS 등록을 통해 OS가 앱을 탐색 할 수 있으며 OS가 탐색 한 후에는 쿼리 문자열에서 토큰에 액세스하는 방법을 보여줍니다. 당신의 앱. 사진의 경우이 토큰은 OnNavigatedTo (NavigationEventArgs e)의 쿼리 문자열 중 "FileId"부분에서 가져옵니다. – Scott