简体   繁体   中英

Playing audio files in background in iOS

I'm trying to find responses to this in Apple's documents, but I don't:

1) Is it technically possible to start playing an audio file when an app goes to background?

2) If technically possible... is it "legal"? Would Apple approve an app that starts playing an audio file without an explicit interaction of the user?

Thanks in advance

An app can start playing an audio file in the background if it is already playing audio before the app goes into the background, has the appropriate audio background mode capabilities key set, and mixes the new audio file into an already playing audio unit, queue or player without stopping. There are plenty of approved apps in the App store that do this (eg they sequence through playlists).

An app can't start playing an audio file in the background if it is not already playing or recording audio, as the OS will take away and disable the app's audio session as it goes into the background.

Reports are that apps that play "silence" to get around this restriction are currently being rejected by Apple, although some legacy examples (alarm clocks?) may still exist in the iOS App store. But for private (non-App-store) apps, this trick currently seems to work just fine.

Also, remote notifications can start playing very short audio files contained within an app's bundle, even if the app is in the background without an active audio session.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM