原始问题(对于Windows Phone 7):我正在使用Windows Phone 7,并希望将下载的播客添加到播放列表中,以便我可以一次性收听它们.不幸的是,UI不允许这样做.我想知道是否有任何API可以做到这一点.
修改后的问题(对于Windows Phone 8):我需要为Windows Phone 8添加“播放列表”api
如果有资格获得赏金,请在此处提供和API参考.除了工作API之外,参考链接或样本将不被接受为正确答案.
(“不可用/不支持”也不接受答案.请不要费心写这些答案)
在我
mentioned on twitter中,在Windows Phone 8中,您可以使用MediaLibraryExtensions在设备的音乐库中添加或删除歌曲. MSDN
here上提到了新功能.但是,我找不到API的任何文档,因此这里是新的Microsoft.Xna.Framework.MediaLibraryExtensions.dll的API打印输出:
原文链接:https://www.f2er.com/windows/372137.html//Microsoft.Xna.Framework.MediaLibraryExtensions,Version=4.0.0.0,Culture=neutral,PublicKeyToken=842cf8be1de50553 namespace Microsoft.Xna.Framework.Media.PhoneExtensions { public static class MediaLibraryExtensions { public static void Delete(MediaLibrary library,Song song); public static String GetPath(Picture picture); public static String GetPathFromToken(MediaLibrary library,String token); public static Stream GetPreviewImage(Picture picture); public static Song SaveSong(MediaLibrary library,Uri filename,SongMetadata songMetadata,SaveSongOperation operation); } public enum SaveSongOperation { CopyToLibrary,MoveToLibrary } public sealed class SongMetadata { public SongMetadata(); public Uri AlbumArtistBackgroundUri { get; set; } public String AlbumArtistName { get; set; } public Uri AlbumArtUri { get; set; } public String AlbumName { get; set; } public DateTime AlbumReleaseDate { get; set; } public Uri ArtistBackgroundUri { get; set; } public String ArtistName { get; set; } public TimeSpan Duration { get; set; } public String GenreName { get; set; } public String Name { get; set; } public Int32 TrackNumber { get; set; } } }
您可以通过使用本地URI调用SaveSong并通过包含自定义SongMetadata来覆盖ID3元数据来使用此新API.此API仅允许您存储新歌曲,但我想您可以将您的播客分组为一位狡猾的艺术家.有关此API的快速说明是确保添加新的DLL引用MediaLibraryExtensions DLL.您还可以将SongMetadata保持为null并让WP8 OS推断出ID3元数据.
这是一个简单的代码片段:
private async void MainPage_Loaded(object sender,RoutedEventArgs e) { var sourceFile = await Package.Current.InstalledLocation.GetFileAsync("ChargeOfTheLightBridge.mp3"); CopyFileIntoIsoStore(sourceFile); var library = new MediaLibrary(); library.SaveSong(new Uri(sourceFile.Name,UriKind.RelativeOrAbsolute),new SongMetadata() { ArtistName = "My Custom Artist",AlbumArtistName = "My Custom Artist",Name = "My Custom Track Name",AlbumName = "clubbing baby seals in the face",Duration = TimeSpan.FromSeconds(29),TrackNumber = 1,AlbumReleaseDate = DateTime.Now,GenreName = "Podcasts" },SaveSongOperation.CopyToLibrary); } private async void CopyFileIntoIsoStore(StorageFile sourceFile) { using (var s = await sourceFile.OpenReadAsync()) using (var dr = new DataReader(s)) using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication()) using (var targetFile = isoStore.CreateFile(sourceFile.Name)) { var data = new byte[s.Size]; await dr.LoadAsync((uint) s.Size); dr.ReadBytes(data); targetFile.Write(data,data.Length); } }
请注意,我们必须在IsoStore中保存文件才能使用此API.另请注意,Uri格式不正确或在标准的IsoStore Uri中.这只是文件名.