Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Unity App Stops External Audio on Launch

Discussion in 'iOS and tvOS' started by kromenak, Mar 1, 2019.

  1. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    266
    We recently upgraded our app from Unity 5.6.5 to Unity 2018.3. We are now noticing that our app will stop any external audio when the app starts.

    For example, if you are playing some music and start the game, the music fades out as the app launches. You can then switch over to the music app and resume music playback. But in previous Unity versions, it seemed that launching the app would not stop external audio.

    Ideally, we'd like our app to respond more elegantly. If external audio is playing, we plan to mute our in-game music. So, we'd like external audio to continue playing.

    In our Player Settings, the "Mute Other Audio Sources" option is disabled. We are also not using any audio plugins that I'm aware of that could interfere with Unity's default audio behavior.

    Has anyone else experienced something like this? Is there anything I can check or change in Xcode to get the desired behavior? Is there any scenario where Unity automatically disables external audio, like if the game itself starts playing music and SFX?
     
  2. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    266
  3. Annopolus

    Annopolus

    Joined:
    Apr 15, 2015
    Posts:
    18
    Unfortunately in version which I'm using 2018.3.12 problem still exist :-(
    Do anyone knows the situation? Should I really wait for 2019.2 as in the issutracker?
     
  4. vlobano

    vlobano

    Joined:
    May 18, 2017
    Posts:
    4
    I'm on 2019.3.0 and it's still there. I can't wait for unity to fix this - customers will be super unhappy with their music stopping in an app that doesn't make any sound. So I ended up just disabling audio stream: in UnityAppController.mm found
    Code (CSharp):
    1. [audioSession setActive: YES error: nil];
    And replaced it with
    Code (CSharp):
    1. [audioSession setActive: NO error: nil];
    (It's better to do it automatically from a postbuild trigger or a bash sed script or whatever)

    There must be a better way, I just don't have time to search for it
     
  5. lostminds

    lostminds

    Joined:
    Jan 17, 2019
    Posts:
    51
    I had a lot of problems with this as well, and a long dialogue with bug report about this. But for me it was eventually fixed in 2019.3.0f4 and it's not a problem for me on later 2019.3.x versions.

    In the meantime, the work-around i found was setting the correct audio session category in XCode in UnityAppController.mm by adding :

    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil]; 

    in

    - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions

    solves the problem for me as a temporary work around.
    That way your app can still play sounds without disrupting other background audio.
     
  6. j1mmie

    j1mmie

    Joined:
    Oct 31, 2013
    Posts:
    27
    Surprised to hear that this was resolved in 2019.3.0f4 because I'm still having the problem in 2019.3.0f6. Is there any existing bug open for this version?
     
  7. Scalisco

    Scalisco

    Joined:
    Feb 2, 2014
    Posts:
    16
    This is still an issue for me in 2019.4.11f1
     
  8. kk3hi3123

    kk3hi3123

    Joined:
    Aug 17, 2016
    Posts:
    31
    Here is 2019.4.21f1. The solutions above do not work for me.
     
  9. FaisalMXR

    FaisalMXR

    Joined:
    Jul 31, 2018
    Posts:
    1
    2019.3.3f1 just got this as well apparently. it was okay last year, but then when I want to revisit this project, this happens.
     
  10. pseudo555

    pseudo555

    Joined:
    Jul 26, 2021
    Posts:
    1
    Still present...
    How hard is it to make a non-regression test on that ?
    It's really annoying for those who need external sound to keep playing. As lazy-ass developers won't solve the issue, why not force the opposite way ? I mean keep external sound ON unless developers say so.
    Players could always stops external sounds if that bother them. But restore sound is a complete different story as... you can't.
     
  11. arthurlucas

    arthurlucas

    Joined:
    Aug 17, 2019
    Posts:
    1
    u Resolve the problem ?