4

If anyone has developed WP apps before you know that you can't pass certification if your app stops music that is currently playing without the users consent.

I did see this question here which might have worked for WP7 apps but it apparently doesn't work for WP8. I assume it doesn't work because the WP8 OS doesn't support XNA (It is only backward compatible, and if you developed the app using 7.1).

Has anyone come across the solution for detecting background music in WP8.

Community
  • 1
  • 1
Edward
  • 7,346
  • 8
  • 62
  • 123

2 Answers2

4

I believe checking for MediaPlayer.GameHasControl is what you're looking for. Use that property and other members of MediaPlayer to satisfy application certification guidelines 6.5.1 Here's an end-to-end example of how @ http://henry-chong.com/2012/02/pro-tip-including-background-music-for-your-windows-phone-app/

BTW, 6.5.x application certification requirements don't apply if your app is a Music+Video app. That's one way to address 6.5.1 :)

JustinAngel
  • 16,082
  • 3
  • 44
  • 73
  • 1
    Note that this will only work with the music played by the Microsoft music player. Other music streaming apps (Nokia Music, Spotify,...) will not resume. That seems to be unavoidable, according to MSDN on background audio architecture:There is only one media queue. Your application cannot pause background audio, play something with MediaElement then resume the background audio stream. – Berthier Lemieux Mar 09 '13 at 20:19
2

I believe that Microsoft.Xna.Framework.Media.MediaPlayer.State is still supported in Windows Phone 8 (MSDN source):

You can reference and use the following XNA Framework assemblies in apps that target Windows Phone OS 8.0:

...

Microsoft.Xna.Framework.Media.dll

...

Community
  • 1
  • 1
Olivier Payen
  • 15,198
  • 7
  • 41
  • 70
  • As stated here http://stackoverflow.com/a/7034556/883738, MediaPlayer.State will be Playing even if you're playing the music. GameHasControl determines if the music was started from your app, or if another app was playing before your app started. – Alex Sorokoletov Oct 26 '13 at 06:23