Ionic version : 5.4.16 / iOS version : 14
I have an hybrid application running under Ionic 5.4 + Vue, and a custom audio player plugin in swift. This swift capacitor plugin allows the user to :
- Play, pause and seek the audio track (uses AVPlayer)
- Download an audio track
- Once downloaded, listen to the audio track in offline mode
The issue : In offline mode, the audio track will cut at a seemingly random time without errors.
It doesn’t matter if the track is very long or very short (heavy or lightweight) : for example a 58min-long track can cut at 6min or 20min in offline mode. A 5min-long track can sometimes cut at 52 seconds. If you press play after that unexpected stop, the track will play again for a few minutes and stop again. What’s even weirder is that when the phone is locked, the CommandCenter seekbar will continue to play even when the track has stopped in-app. This only happens when emulating on a physical device but not on an Xcode Simulator.
Further information :
- In the config.xml file, the APPBackgroundMode is set to true
- In the Info.plist file, the UIBackgroundModes is enabled with the « audio » string
- ionic BackgroundMode plugin is enabled
Despite trying to catch an error in the swift custom plugin, no error is returned in Xcode when the track stops playing. I am running out of ideas on how to debug this since I can’t seem to get an error.