Audio stops playing after some time on iOS (works fine on Android)

Hi everyone,

I’ve developed a quiz app that plays short sound effects during gameplay (for example, when answering questions or showing results). On Android everything works perfectly, but on iOS the sound randomly stops working after some time — the app itself continues to function normally, but no more audio is played.

The issue seems to occur after the app has been running for a while. Restarting the app temporarily fixes it.

I’m using AdMob for ads, so I’m wondering if there could be a conflict between the AdMob plugin and the audio playback (for example, if the audio session is being interrupted or not restored correctly after an ad).

Has anyone experienced similar behavior on iOS?
Any ideas or suggestions on how to debug or prevent the audio from stopping would be greatly appreciated.

Here are the store links in case you want to check the app:

iOS: ‎Brain Clash on the App Store

Android: https://play.google.com/store/apps/details?id=it.mgdlab.app.brainclash

Thanks in advance for any help!

How are you playing audio? Are you using a native plugin or web players? If web, you are going to run into issues especially with long playing audio.

The following native plugins are available that I am aware of:

honetly speacking i have use must of them mediagrid and capgo but once javasccript go on doze mode the music stop working becuase javascript is no longer working.

Interesting. I can only speak on the mediagrid plugin since I maintain it and use it in my app. Javascript definitely goes to sleep on both Android and iOS after a period of time if the app is not active so any logic for next audio track or listeners won’t fire until the app wakes back up. However, the current audio track should keep playing since it is playing natively (I’ve not experienced any issues here).

I’ve wanted to revamp the plugin so more stuff is native but haven’t had the time.

oh great, once Android and IOS short down javascript it almost imposible to get it back oworking excep you open the app , i think it capacitor issue not plugin issue not suppose to short down javscript when playing medias

thanks everyone i have resolve the issue by buiding my own capacitor exoplayer and adding queue feature to my antvie plugin just incase javascript go to sleep the native level still have the queue to continue from "