I can play audio when my app is in forground, and it works when it goes to background.
but it doesn’t start playing when app is in backgroud. so is it posible to start playing audio in background, i’m using avaudioplayer. i have added in info plist key : Required Background Modes -> App Plays Audio
The way I understand multitasking works, when the user taps the home button or resumes another app from the “Recently used apps” tray (double tap home button), your app gets about 5 seconds in the “Backgrounded State”, and after that it enters the “Frozen State”. During those 5 seconds, you can execute code (e.g., start playback) but you can’t do anything UI/Graphics-related. Once your app enters the “Frozen State”, its state is preserved in RAM but it can NOT execute any code; i.e. it gets 0 CPU cycles and in fact it is NOT running, so you can’t start any new task.
During the transition described above, you can request extra time beyond those 5 seconds to complete specific tasks, effectively extending the “Background State” to, for example, complete a download.