Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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

DZone's Guide to

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

· Mobile Zone
Free Resource
You can get the get the list of Songs, Genres, and Albums from the Windows Phone by using the MediaLibrary class defined in the Microsoft.Xna.Framework.Media Namespace.

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 Microsoft.Xna.Framework.Media;

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 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 Genre property to find Songs by Genre


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;

 


Source: http://windowsphonerocks.com/Developer/DeveloperArticles/tabid/64/Article/185/how-to-get-the-list-of-songsgenresalbums-from-the-windows-phone-medialibrary.aspx

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}