Playing a Song causing WP7 to crash on phone, but not on emulator
- by Michael Zehnich
Hi there,
I am trying to implement a song into a game that begins playing and continually loops on Windows Phone 7 via XNA 4.0. On the emulator, this works fine, however when deployed to a phone, it simply gives a black screen before going back to the home screen. Here is the rogue code in question, and commenting this code out makes the app run fine on the phone:
// in the constructor fields
private Song song;
// in the LoadContent() method
song = Content.Load<Song>("song");
// in the Update() method
if (MediaPlayer.GameHasControl && MediaPlayer.State != MediaState.Playing)
{
MediaPlayer.Play(song);
}
The song file itself is a 2:53 long, 2.28mb .wma file at 106kbps bitrate.
Again this works perfectly on emulator but does not run at all on phone. Thanks for any help you can provide!