# Audio stops when ios app goes to lock screen

**URL:** <https://qa.fmod.com/t/audio-stops-when-ios-app-goes-to-lock-screen/22208>\
**Category:** Unity\
**Created:** [October 22, 2024, 10:26am UTC](https://qa.fmod.com/t/audio-stops-when-ios-app-goes-to-lock-screen/22208 "2024-10-22T10:26:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alborada](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@alborada](https://qa.fmod.com/u/alborada)\
**Post date:** [October 22, 2024, 10:26am UTC](https://qa.fmod.com/t/audio-stops-when-ios-app-goes-to-lock-screen/22208/1 "2024-10-22T10:26:12Z")

</div>

Hello, I’ve made an app using Unity 2022.3.26f1 and the latest fMod, I’m struggling to get it to continue to play audio in the background on an iphone when the screen is off or the phone is locked.  
I understand how to do this via Signing&Capabilities, and using the correct Audio Session via AppDelegate, but can’t get it to work. It will play when the app loses focus (i.e. on home screen) but when phone locks it stops.

Is this something to do with using fMod as the audio engine instead of Unity’s?

---

<div class="post-metadata">

**Author:** ![Capraise](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@Capraise](https://qa.fmod.com/u/Capraise)\
**Post date:** [October 27, 2024, 12:58pm UTC](https://qa.fmod.com/t/audio-stops-when-ios-app-goes-to-lock-screen/22208/2 "2024-10-27T12:58:55Z")

</div>

> [@alborada](#):
>
> and using the correct Audio Session via AppDelegate

Which AVAudiosession Category do you have set in the startUnity method in the UnityAppController.mm file?

Try replace:

```auto
[audioSession setCategory: AVAudioSessionCategoryAmbient error: nil];

```

with:

```auto
[audioSession setCategory: AVAudioSessionCategoryPlayback error: nil];

```

(Given you’ve disabled unity audio. Else you could add it outside the if statement).

And as you said, the audio background mode should be added in the capabilites.

---

<div class="post-metadata">

**Author:** ![alborada](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@alborada](https://qa.fmod.com/u/alborada)\
**Post date:** [October 29, 2024, 9:32am UTC](https://qa.fmod.com/t/audio-stops-when-ios-app-goes-to-lock-screen/22208/3 "2024-10-29T09:32:48Z")

</div>

Thanks! I did have it set up that way; turns out the problem was a memory one- the fmod buffer size was not big enough within Unity which caused problems when the app lost focus.

---

<div class="post-metadata">

**Author:** ![Capraise](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@Capraise](https://qa.fmod.com/u/Capraise)\
**Post date:** [November 3, 2024, 8:19pm UTC](https://qa.fmod.com/t/audio-stops-when-ios-app-goes-to-lock-screen/22208/4 "2024-11-03T20:19:26Z")

</div>

Ah, that’s good to know, if I ever run into this. Thanks for the update!

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [November 3, 2024, 9:44pm UTC](https://qa.fmod.com/t/audio-stops-when-ios-app-goes-to-lock-screen/22208/5 "2024-11-03T21:44:19Z")

</div>

Thank you for sharing the solution.

---

<div class="post-metadata">

**Author:** ![Orbinaut](https://avatars.discourse-cdn.com/v4/letter/o/b38774/32.png) [@Orbinaut](https://qa.fmod.com/u/Orbinaut)\
**Post date:** [June 22, 2025, 3:25am UTC](https://qa.fmod.com/t/audio-stops-when-ios-app-goes-to-lock-screen/22208/6 "2025-06-22T03:25:03Z")

</div>

You are my personal hero.
