Question

I am creating an app for music player, but in my Emulator there are no music files

So I decided to add few songs in MediaLibrary

I wrote following code to add songs:

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)
            {

            }
        }

but it is not working, I don't know why

enter image description here enter image description here

Anyone have an idea?

Était-ce utile?

La solution

This answer should be enough for what you are trying to do:

http://stackoverflow.com/a/23041512/1537726
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top