How to get the list of Songs, Genres, Albums from the Windows Phone MediaLibrary
Join the DZone community and get the full member experience.
Join For FreeTo 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;
Opinions expressed by DZone contributors are their own.
Comments