Detecting if Zune is playing music?

Monkey Targets Forums/XNA/Detecting if Zune is playing music?

Uncle(Posted 2012) [#1]
Hello,

More windows mobile fun. While trying to get our game on the store it was rejected because we don't meet the following requirements...

Requirements

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 Microsoft.Xna.Framework.Media.MediaPlayer the class.
If the application plays its own background music or adjusts background music volume, it must ask the user for consent to stop playing/adjust the background music (e.g. message dialog or settings menu). This prompt must occur each time the application launches, unless there is an opt-in setting provided to the user and the user has used this setting to opt-in.




Is there a way to detect if there is music already playing in Zune? Has anyone else come across this when submitting games?

Cheers,


Andrew


OvineByDesign(Posted 2012) [#2]
As a quick hack ive inject this code to auto mute in game sounds......


public static int g_load(){

        if (MediaPlayer.GameHasControl == false)
        {
            g_soundOn = 0;
        }



Are we able todo this from within monkey code ?


OvineByDesign(Posted 2012) [#3]
I guess this should work

#if TARGET="xna"
    Extern
    Function zuneplaying:int() = "public int zuneplaying(){ return MediaPlayer.GameHasControl}"
    Public
#end

and in .......

Method OnCreate()
    #if TARGET="xna"
        if zuneplaying() Then
            g_soundOn = 0
        EndIf
    #end
...
.
.




OvineByDesign(Posted 2012) [#4]
The above didnt work so heres a working version. Check for the Zune Media player playing music and auto select mute on game start.....


Import mojo

#if TARGET="xna"
    Extern
    Global IsZunePlaying?="!MediaPlayer.GameHasControl"
    Public
#end

Function Main()
    #if TARGET="xna"
        if IsZunePlaying Then
            soundOn = 0
        EndIf
    #end
End



dave.h(Posted 2012) [#5]
Thanks for posting this code ive just inserted it into my app and it works great.


OvineByDesign(Posted 2012) [#6]
glad to share...


marksibly(Posted 2012) [#7]
Hi,

Does this apply to music AND sound, or just music?

The requirements makes it sound like music only, but your code looks like it's nuking all audio.

If I add this to mojo, is it OK to just disable music? This is what I think they mean, and also what I think would be most user friendly.


Raz(Posted 2012) [#8]
Would "IsZunePlaying" on it's own be enough, and then let the game maker decide how to act upon its current value?


OvineByDesign(Posted 2012) [#9]
I used this as reference

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.media.mediaplayer.gamehascontrol.aspx

I took this as music only - and indeed it passed the windows criteria.


dave.h(Posted 2012) [#10]
i just upgraded my free app and it passed but i recieved an email saying that future versions will need to test for if zune is playing.My app didnt play any music so i didnt test for it but according to this email they want me to test for it in future updates.Cant see the point really but its no hardship adding the code.


marksibly(Posted 2012) [#11]
Hi,

> future versions will need to test for if zune is playing.My app didnt play any music

...which would imply music AND sound must be disabled!

Confusing - could you possibly get them to clarify? The requirements seem to suggest just music.


dave.h(Posted 2012) [#12]
its just music.Even though i didnt play music in the app i had left a stopmusic command in without realising it which i assumed stopped zune.Strange that it passed first time though and they even passed an update.