I should have known better. I gave half dozen presentations on the Windows Phone Marketplace certification process. I however, forgot to test for certification requirement 6.5.1 for my own app which states:
Requirements Expected Result When the user is already playing music on the phone when the application is launched, the application must not pause, resume, or stop the active music in the phone MediaQueue by calling the Microsoft.Xna.Framework.Media.MediaPlayer class. The application needs to prompt the user for consent to adjust the volume or stop the music that is currently playing in the Zune queue. Note: This requirement does not apply to applications that play sound effects through the Microsoft.Xna.Framework.Audio.SoundEffect class, as sound effects will be mixed with the MediaPlayer. The SoundEffect class should not be used to play background music. Note: This requirement does not apply to Music + Videos hub applications that are described in Section 6.4.
Requirements Expected Result When the user is already playing music on the phone when the application is launched, the application must not pause, resume, or stop the active music in the phone MediaQueue by calling the Microsoft.Xna.Framework.Media.MediaPlayer class. The application needs to prompt the user for consent to adjust the volume or stop the music that is currently playing in the Zune queue.
Note: This requirement does not apply to applications that play sound effects through the Microsoft.Xna.Framework.Audio.SoundEffect class, as sound effects will be mixed with the MediaPlayer. The SoundEffect class should not be used to play background music.
Note: This requirement does not apply to Music + Videos hub applications that are described in Section 6.4.
Test Process Required: 1. Play audio and/or music media. 2. Launch the application. 3. The application must not pause, resume, or stop the active music on the device. 4. If the application plays its own background music, the application must prompt for user consent to stop playing or to adjust the currently playing background music.
Ok so now that we know the requirements, how do we satisfy it? It is actually pretty easy. The MediaPlayer class gives us a static property (State) for us to get its current state. Once we know the status, we can then give the user the choice of stopping the media player so we can play our own.
if (Microsoft.Xna.Framework.Media.MediaPlayer.State == MediaState.Playing) { MessageBoxResult Choice; Choice = MessageBox.Show("Media is currently playing, do you want to stop it?", "Stop Player", MessageBoxButton.OKCancel); if (Choice == MessageBoxResult.OK) mediaElement1.Play(); } This code on a method that gets called in the constructor of the class and should be called any time you call the play method of the MediaElement class.
if (Microsoft.Xna.Framework.Media.MediaPlayer.State == MediaState.Playing)
{
MessageBoxResult Choice;
Choice = MessageBox.Show("Media is currently playing, do you want to stop it?", "Stop Player", MessageBoxButton.OKCancel);
if (Choice == MessageBoxResult.OK)
mediaElement1.Play();
}
Hope this helps.