Home > Windows Phone > Playing a song from library – WP8

Playing a song from library – WP8

Here is the logic to play a particular song from library.

Logic is to loop through all the songs in Media Library and if the song name matches to our song play the song.

string favoriteSong = “mySong.mp3”;

using (Microsoft.Xna.Framework.Media.MediaLibrary library = new Microsoft.Xna.Framework.Media.MediaLibrary())            {

foreach (var song in library.Songs)                {

if (song.Name == favoriteSong) {


// Play the song








  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: