I am using the media player in Windows Phone 7 to play the music in the phone song collection. But when it play the music they will be an exception and the error is stating
You have to call
FrameworkDispatcher.Update()
whenever you make a call to an XNA media library so your code should look like this
using (var ml = new MediaLibrary())
{
foreach (var song in ml.Songs)
{
System.Diagnostics.Debug.WriteLine(song.Artist + " " + song.Name);
MessageBox.Show(song.Artist + " " + song.Name);
}
FrameworkDispatcher.Update();
MediaPlayer.Play(ml.Songs[0]);
}
The error is occouring because you're using the XNA Framework in a regular Windows Phone 7 application.
If you read the error description, you would gotten this link to MSDN: Enable XNA Framework Events in Windows Phone Applications , which explains precisely what to do.