开发者

iOS: allow user to choose whether audio will play in background or not

开发者 https://www.devze.com 2023-01-30 00:15 出处:网络
My app is able to play audio in the background. However, I\'d like for it to not play audio in the background by default. I\'d like to have a user preference which controls whether audio is played in

My app is able to play audio in the background. However, I'd like for it to not play audio in the background by default. I'd like to have a user preference which controls whether audio is played in the background or not.

开发者_如何学编程

Background audio is controlled via UIBackgroundModes info.plist. If I use this setting to allow background audio, my app will always play audio in the background. Is there a programmatic way to display playing audio in the background? Or do I need to do something less graceful, like fading audio in and out on my own when the app enters or leaves the background state?


Either depend on the Settings app, or provide the user a way in your app to set this preference, before your app is put in the background. Then continue to play or cut the sound depending on that setting, assuming you have set UIBackgroundModes to give your app the option.

0

精彩评论

暂无评论...
验证码 换一张
取 消