iOS:允许用户选择音频是否在后台播放
我的应用程序能够在后台播放音频。但是,我希望它默认情况下不在后台播放音频。我想要一个用户首选项来控制是否在后台播放音频。
背景音频通过 UIBackgroundModes info.plist 控制。如果我使用此设置允许背景音频,我的应用将始终在后台播放音频。是否有一种编程方式可以在后台显示正在播放的音频?或者我是否需要做一些不太优雅的事情,例如当应用程序进入或离开后台状态时自行淡入和淡出音频?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要么依赖于“设置”应用,要么在您的应用程序置于后台之前为用户提供一种在应用程序中设置此首选项的方法。然后根据该设置继续播放或剪切声音,假设您已设置 UIBackgroundModes 为您的应用程序提供该选项。
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.