My application failed today because of certification rule 6.5 Application that Play Music section 6.5.1. Before I get into how to fix it here is the requirements and failed result.
6.5.1 Requirement
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.
Expected Result
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.
Steps to reproduce:
1. Play any music on the device.
2. Launch the application.
3. Select one of the duck caller types displayed on the screen.
4. Notice the application stops the current music without prompting the user.
Using MediaPlayer.GameHasControl to fix the issue
This is very simple to address by using MediaPlayer.GamehasControl which is part of Microsoft.Xna.Framework.dll with namespace Microsoft.Xna.Framework.Media. It will return false if there are some background music currently being played and you must prompt the user for the permission to stop the background music and play your own sound.
Here is the code snippet from the DuckCaller application to handle this shown below:
private void PlaySound(string soundFile)
{
bool canPlay = false;
FrameworkDispatcher.Update();
if (MediaPlayer.GameHasControl)
{
canPlay = true;
}
else
{
if (MessageBox.Show(“Is it ok to stop currently playing
music and play our duck caller sound?”, “Can play duck caller?”,
MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
canPlay = true;
}
}
if (canPlay)
{
btnPlay.Visibility = System.Windows.Visibility.Collapsed;
btnPause.Visibility = System.Windows.Visibility.Visible;
_updatingMediaTimeline = true;
mediaDuckSound.Stop();
mediaDuckSound.Source = new Uri(soundFile, UriKind.Relative);
mediaDuckSound.Position = System.TimeSpan.FromSeconds(0);
mediaDuckSound.Volume = 1;
mediaDuckSound.Play();
ShowBuyNow();
}
}
Conclusion
I am glad that Microsoft goes into this much detail to care about the user experience. This definitely will help in publishing the quality with consistent user experience.


Perfect – I had everything but the FrameworkDispatcher.Update()! Thank you very much.
One question though, I believe that article 6.5.3 states that you must resume the playing of the music that was previously playing if your app attempts to show video. How would you suggest going about this?
“6.5.3 Applications that Play a Video or Audio Segment
An application may interrupt the currently playing music to play a non-interactive full motion video or audio segment (e.g. cut-scene or media clip) without asking for user consent. If music was playing prior to the segment, the application must resume music when the segment has completed.”
This will apply equally to Video because you can not disrupt background music. Good way to test this is from your app press windows key which will tombstone out to of your app. And when you come back to your at it will resume and you have to handle the case otherwise you will get rejected.
Pingback: How to handle Application test failed – Error: 6.5 Applications that Play Music? | Toetapz's Blog
i recieve an error:
Error 1 The type or namespace name ‘Xna’ does not exist in the namespace ‘Microsoft’ (are you missing an assembly reference?)
i use this:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;
how do you assign the name for media control items?
and how to pass the song thats playing in the background to the method PlaySound?
thanks
There is nice instruction on MSDN for this.