如何在Windows Phone模拟器中保存音乐文件?

时间:2014-04-16 05:55:51

标签: c# windows-phone-7 windows-phone-8 microsoft-metro windows-store-apps

我正在为音乐播放器创建一个应用,但在我的模拟器中没有音乐文件

所以我决定在MediaLibrary

中添加几首歌曲

我写了以下代码来添加歌曲:

public void addsong()
        {
            try
            {
                Uri songUri = new Uri("../Assets/samplemusic/02 Can't Remember to Forget You (feat. Rihanna).mp3", UriKind.RelativeOrAbsolute);

                //SaveFileToIsolatedStorage(songUri, "test.mp3");

                MediaLibrary lib = new MediaLibrary();

                SongMetadata metadata = new SongMetadata

                {

                    GenreName = "Super Hit Songs",

                    Name = "Song 1",

                    AlbumName = "My Collections",

                    AlbumArtUri = new Uri("ApplicationIcon.png", UriKind.RelativeOrAbsolute)

                };

                MediaLibraryExtensions.SaveSong(lib, songUri, metadata, SaveSongOperation.CopyToLibrary);
            }
            catch (Exception ex)
            {

            }
        }

但它不起作用,我不知道为什么

enter image description here enter image description here

有人有想法吗?

1 个答案:

答案 0 :(得分:0)

这个答案应该足以满足您的目的:

http://stackoverflow.com/a/23041512/1537726