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

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

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

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}