问题
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.
回答1:
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 :)
回答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
...
来源:https://stackoverflow.com/questions/13734071/how-to-detect-if-background-music-is-playing-in-wp8