Media Player and Marketplace Certification with Windows Phone

London Building

One of our students was having problems with Marketplace Certification for his XNA game. The game was failing certification because his game background music was playing over the top of any media that the phone user was listening to. There is a simple way to fix this, which is not to play your game music if the user is listening to something. You can do this by testing to see if the media player is stopped before playing your music:

if (MediaPlayer.State == MediaState.Stopped)
    // play your own music here

The MediaPlayer class lives in the System.XNA.Media namespace. If you are writing a Silverlight game you’ll have to import the XNA libraries.