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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Audio background mode (audio) not working..

Discussion in 'Audio & Video' started by mfgage, Nov 25, 2017.

  1. mfgage

    mfgage

    Joined:
    Jun 4, 2013
    Posts:
    24
    Audio was playing in the background until recently because I was checking that option off in XCode, but now...

    I was advised I was using 'Prepare iOS for recording' and this was the reason my speaker audio was low, but now that I took that out...

    Audio will not pay in the background now, but it would with recording enabled.

    Thanks in advance.
     
  2. mfgage

    mfgage

    Joined:
    Jun 4, 2013
    Posts:
    24
    RESOLVED.

    FYI..
    I used solutions based on info from these 2 people:
    aihodge & mbaker ---- Thanks!
    (It's an update from an old thread I started, but the solution probably needed to change years later because of Unity updates) https://forum.unity.com/threads/how-do-i-get-the-audio-running-in-background-ios.319602/

    SOLUTION:
    --------
    At the bottom of the startUnity() method I put this code:
    ---
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlaybackerror:nil];
    [[AVAudioSession sharedInstance] setActive: YESerror: nil];
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
     
  3. DidierAubin

    DidierAubin

    Joined:
    Nov 28, 2017
    Posts:
    9
    Uhm... I met the same problem, I could not remember how I fixed it but suddenly it was fine after a few days