Playing a Song causing WP7 to crash on phone, but not on emulator
        Posted  
        
            by 
                Michael Zehnich
            
        on Game Development
        
        See other posts from Game Development
        
            or by Michael Zehnich
        
        
        
        Published on 2011-01-28T20:38:45Z
        Indexed on 
            2011/01/28
            23:39 UTC
        
        
        Read the original article
        Hit count: 468
        
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!
© Game Development or respective owner