api windows-phone-7 windows-phone-8 playlist zune

API para agregar listas de reproducción en Zune



windows-phone-7 windows-phone-8 (2)

No hay medios predeterminados para acceder a la API de Zune. Puede hacerlo a través de formas no documentadas (capa nativa), pero finalmente obtendrá su aplicación rechazada del Mercado.

Pregunta original (para Windows Phone 7): Estoy usando Windows Phone 7 y me gustaría agregar podcasts descargados a una lista de reproducción para poder escucharlos de una sola vez. Lamentablemente, la IU no permite esto. Me gustaría saber si hay alguna API para hacer esto.

Pregunta modificada (para el teléfono de Windows 8): Necesito la API "agregar a la lista de reproducción" para el teléfono con Windows 8

Para tener derecho a la recompensa, proporcione una referencia API aquí. Aparte del enlace de referencia o muestra de API que funciona no se aceptará como una respuesta correcta.

("No disponible / no compatible" tampoco será aceptado como respuesta. No se moleste en escribir este tipo de respuesta)


Como mencioné en twitter , en Windows Phone 8 puedes agregar o eliminar canciones de la biblioteca de música del dispositivo usando MediaLibraryExtensions. La nueva capacidad se menciona en MSDN aquí . Sin embargo, no pude encontrar ninguna documentación para las API, así que aquí está la impresión de la API para el nuevo Microsoft.Xna.Framework.MediaLibraryExtensions.dll:

//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; } } }

Puede utilizar esta nueva API invocando a SaveSong con un URI local y potencialmente anulando los metadatos ID3 incluyendo un SongMetadata personalizado. Esta API solo te permite almacenar nuevas canciones, pero supongo que puedes agrupar tus podcasts en un artista faccioso. Una nota rápida sobre esta API es asegurarse de agregar la nueva DLL de MediaLibraryExtensions de referencia de DLL. También puede mantener SongMetadata como nulo y tener el SO WP8 inferir metadatos ID3.

Aquí hay un fragmento de código simple:

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, 0, data.Length); } }

Tenga en cuenta que tuvimos que guardar un archivo en IsoStore para usar esta API. También tenga en cuenta que el Uri no está bien formado o en un IsoStore Uri estándar. Es solo el nombre del archivo.

Cuando ejecutamos este fragmento de código, podemos ver lo siguiente: