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) {
FrameworkDispatcher.Update();
// Play the song
Microsoft.Xna.Framework.Media.MediaPlayer.Play(song);
break;
}
}
library.Dispose();
}
🙂
Categories: Windows Phone
media palyer, Play song, WP 8
Comments (0)
Trackbacks (0)
Leave a comment
Trackback