How do you allow background music from another app to continue playing

I'm trying to set it up so that my game will allow the user to turn off the sounds and allow the music already playing from a background app like iTunes to keep playing. However, even if I don't initialize the Sound Engine, the background audio is turned off when my game starts.

How can prevent a CocosSharp app from taking the audio focus?


  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    Hey Steven

    That is not possible right now but what platforms specifically are you looking to target for this.

  • I'm looking for it on iOS and Android. However, I did figure it out for the iOS side at least. At the start of the AppDelegate in the iOS specific project I put the following lines, and then I have a flag that doesn't start my internal background music. The sound effects play over the iTunes music

    AudioSession.Initialize ();
    AudioSession.Category = AudioSessionCategory.AmbientSound;

    These classes are found in the AudioToolbox namespace.

  • Hey Steven

    Did you figure out how to get this working on Android?

  • AakashChoubeyAakashChoubey USMember ✭✭

    when application audio is active mode, then background music is pause,then application audio active mode is end, in this condition background music should be run from resume. Is it possible in ios xamarin ?

Sign In or Register to comment.