2013-04-27 45 views
1

我有從MediaLibrary返回的宋對象。如何獲得文件名的uri或絕對路徑?任何未發佈的API?構造函數具有用於構造Song對象的FromUri。想知道是否有辦法檢索它?它似乎來自MediaLibraryExtensions的GetPathFromToken。但是我需要提出什麼樣的「標誌」?謝謝!可溼性粉劑:可能得到uri微軟.Xna.Framework.MediaSong

回答

1

回答「我需要什麼令牌?」
標記的值被提供給上時該應用程序註冊到擴展Windows電話OS的不同部分,這包括Photo Share PickerPhoto Edit PickerAuto 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或路徑。

+0

謝謝。如果還有其他未發佈的API可以獲取歌曲對象的路徑,請分享一下嗎? :) – thsieh 2013-08-06 01:36:25

+0

@thsieh對不起,我不熟悉任何未公開的API,最好的辦法是搜索黑客社區和/或計算器。 Win Phone 7中的無證API有很多進展,但我不確定Win Phone 8上有多少進展,因爲它更加鎖定。請注意,如果您使用任何未公開的API,則您的應用幾乎肯定會通過認證失敗,並且永遠無法存在於App Store中。 – Scott 2013-08-06 02:28:58

相關問題