How to get the list of Songs,Genres,Albums from the Windows Phone MediaLibrary ?

You can get the Get the List of Songs / Albums from the Windows Phone using the MediaLibrary class defined in the Microsoft.Xna.Framework.Media Namespace .

How to access MediaLibrary ?

To access the MediaLibrary Class , you should add the reference of the Microsoft.xna.Framework dll to your Windows Phone Application and add the following Namespace


Add the following code snippet

private void ListSongs()
   MediaLibrary lib = new MediaLibrary();
   var SongName = (from m in lib.Songs
   select m.Name).ToList();
   listBox1.ItemsSource = SongName;

The MediaLibrary Class includes the Songs property which is a SongsCollection . In the Above example the the LINQ Query is used to retreive the Names of the songs from the Songs Collection .

You should see the list of songs as shown below .

Did you notice the list of songs in Emulator ?

  • Another Melody Song
  • Melody Song
  • Rhythm Variation

These are the default songs that are included in the Emulator

The MediaLibrary class also includes the properties Genres to get the kind of Songs

MediaLibrary lib = new MediaLibrary();
var Genre = (from m in lib.Genres
select m.Name).ToList();
listBox1.ItemsSource = Genre;

You can also display the Albums using the property Albums defined in the MediaLibrary class

MediaLibrary lib = new MediaLibrary();
var Albums = (from m in lib.Albums
select m.Name).ToList();
listBox1.ItemsSource = Albums;


If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

2 Responses

Leave a Reply