Search Unity

App disables background music

Discussion in 'iOS and tvOS' started by C-Gabriel, Jan 21, 2019.

  1. C-Gabriel

    C-Gabriel

    Joined:
    Jan 27, 2016
    Posts:
    119
    Hi,

    I'm trying to make my app not disable the background music (Spotify for example) when it loads. I've tried to put
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
    both in
    UnityController.mm  application:didFinishLaunchingWithOptions
    and
    UnityController.mm startUnity()
    If my app gets loaded in the background -> load Spotify and play some music -> resume to my app, it works fine, but if I start Spotify first and then start my app, the music will stop. How can I fix this? Sorry if this has been asked before, but I couldn't find anything.

    // Edit
    Unity 2018.3.0f2
    Xcode 10.1

    // Later edit
    I think there should be a dropdown list with all AVASessionCategories in the Player Settings to force the app start in that specific mode instead of finding workarounds

    Thanks
     
    Last edited: Jan 21, 2019
  2. C-Gabriel

    C-Gabriel

    Joined:
    Jan 27, 2016
    Posts:
    119
    It looks like there has been a bug report with this issue for a couple of days now. Is there any work around this? I am looking to test my app within the next couple of days, and this could have quite a bit of an impact on the retention.
     
  3. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    I had an issue years ago where a user reported their iPhone would not play their own music while playing my game. I reproduced the issue and solved it by not having any MP3 files playing in my game. I switched my music file from MP3 to WAV.
     
  4. C-Gabriel

    C-Gabriel

    Joined:
    Jan 27, 2016
    Posts:
    119
    Thanks for the tip @moonjump , but I've implemented FMOD for now and it works very well. I might not even go back to unity's audio system after all :)