JohnCE
JohnCE

Reputation: 83

How to get a list of songs, artists, albums on WP7 devices?

I want to create a simple audio player for Windows Phone 7. How can I get a list of songs, artists, albums, genres and method to play item which i selected ? something like is in native wp7 app "Music+Videos"

second problem: I downloaded "Music + Videos Hub Sample" from Code samples, I execute this project and it play some song, display title and coverart of song BUT... when I copy this code, add references etc to my project then not display coverart and display title of song, why?

Where i can find more samples of media player for wp7?

Upvotes: 2

Views: 1451

Answers (3)

Rxhns
Rxhns

Reputation: 1

Here is a simple code example I'm using to display the cover art for the currently playing song:

BitmapImage image = new BitmapImage();
                image.SetSource(MediaPlayer.Queue.ActiveSong.Album.GetAlbumArt());

Upvotes: 0

user887973
user887973

Reputation: 21

John, I don't know if you solved the trouble, but i noticed when I put this code together that the PopulateSongMetadata() method was never actually called. This is what you are probably missing. Make sure PhoneApplicationPage_Loaded is actually loaded. Ensure this in your Page's xaml file by adding Loaded="PhoneApplicationPage_Loaded" to the page's

Upvotes: 1

keyboardP
keyboardP

Reputation: 69372

You can use the MediaLibrary to access the songs, artists and albums on the user's device.

using(MediaLibrary library = new MediaLibrary())
{
     SongCollection songs = library.Songs;
     Song song = songs[0];
     MediaPlayer.Play(song);
}

For your second problem, did you copy the artwork over as well as the code and references? Some samples, other than the one you've downloaded include this and this. The MediaPlayer isn't a particularly complex class, it has the basic play, stop, pause etc.. methods. The second sample link provides a music manager that demonstrates how to handle certain events (such as a phone call) when using the MediaPlayer.

Upvotes: 2

Related Questions