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) {

FrameworkDispatcher.Update();

// Play the song

Microsoft.Xna.Framework.Media.MediaPlayer.Play(song);

break;

}

}

library.Dispose();

}

🙂

Leave a Reply

Visitors

2,237,546 hits

Top Posts

Discover more from Rajeev Pentyala – Technical Blog on Power Platform, Azure and AI

Subscribe now to keep reading and get access to the full archive.

Continue reading