API添加播放列表中的Zune [英] API to add playlists in Zune

查看:207
本文介绍了API添加播放列表中的Zune的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原始的问题(为Windows Phone 7):我使用Windows Phone 7和想下载的播客添加到播放列表中,这样我可以在一个单一的去听取他们的意见。不幸的是UI不允许这样。我想知道是否有任何的API来做到这一点。

Original Question (for windows phone 7): I am using windows phone 7 and would like to add downloaded podcasts to a play list so that I can listen to them in a single go. Unfortunately UI does not allow this. I would like to know whether there are any API to do this.

修改的问题(对于Windows Phone的8):我需要添加到播放列表的API的Windows Phone 8

Modified Question (for windows phone 8): I need "add to playlist" api for windows phone 8

有关正在题为赏金请提供和API参考这里。比工作API参考链接或其它样品将不被接受为正确答案。

For being entitled for bounty please provide and API reference here. Other than working API reference link or sample will not be accepted as a correct answer.

(无/不支持也将不被接受的答案。请不要刻意去写这些样的回答)

推荐答案

正如我在Windows手机在Twitter上提到, 8,你可以添加或使用MediaLibraryExtensions从设备的音乐库中删除歌曲。这一新功能是在MSDN <一提到href=\"http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402541.aspx#BKMK_Medialibrary\">here.但是,我找不到对API的任何文件,所以这里的新Microsoft.Xna.Framework.MediaLibraryExtensions.dll API的打印输出:

As I mentioned on twitter, in Windows Phone 8 you can add or remove songs from the device's music library using MediaLibraryExtensions. The new capability is mentioned on MSDN here. However, I couldn't find any documentation for the APIs, so here's the API printout for the new 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; }
    }
}

您可以通过与当地的URI调用SaveSong以及由包括自定义SongMetadata可能重写ID3元数据使用这个新的API。这个API只允许你存储新的歌曲,但我想你可以争论的一个艺术家小组下你的播客。这个API快速值得注意的是,以确保增加新的DLL参考MediaLibraryExtensions DLL。您也可以可以保持SongMetadata为空,并有WP8操作系统推断ID3元数据。

You can use this new API by invoking SaveSong with a local URI and by potentially overriding the ID3 metadata by including a custom SongMetadata. This API only allows you to store new songs, but I guess you can group your podcasts under a factious artist. Quick note about this API is to make sure to add the new DLL reference MediaLibraryExtensions DLL. You can also can keep SongMetadata as null and have the WP8 OS infer ID3 metadata.

下面是一个简单的code片断:

Here's a simple code snippet:

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

请注意,我们必须将文件保存在IsoStore使用这个API。还要注意的是开放的不充分形成,或者在标准IsoStore URI。这只是文件名。

Note that we had to save a file in IsoStore to use this API. Also note that the Uri isn't well-formed or in a standard IsoStore Uri. It's just the file name.

当我们运行这个code段我们可以看到以下内容:

When we run this code snippet we can see the following:




这篇关于API添加播放列表中的Zune的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆