1

MediaLibrary から返された Song オブジェクトがあります。ファイル名を含む uri または絶対パスを取得するにはどうすればよいですか? 未公開の API はありますか? コンストラクターには、Song オブジェクトの構築に使用される FromUri があります。それを取り戻す方法があるのだろうか?MediaLibraryExtensions からの GetPathFromToken のようです。しかし、私が考え出す必要がある「トークン」は何ですか? ありがとう!

4

1 に答える 1

1

「私が思いつく必要があるトークンは何ですか?」に答えるために。質問の一部:
アプリケーションが Windows Phone OS のさまざまな部分を拡張するために登録されると、トークンの値がクエリ文字列でアプリケーションに提供されます。これには、Photo Share PickerPhoto Edit Picker、およびファイル関連付けからの自動起動が含まれます

すべての例で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 に答える