如何处理后台音频播放,而iOS设备被锁定,或者在另一个应用程序? [英] How to handle background audio playing while iOS device is locked or on another application?

查看:797
本文介绍了如何处理后台音频播放,而iOS设备被锁定,或者在另一个应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设计iOS版生成音乐系统,采用了openFrameworks,我需要提供其中用户可以收听由应用程序产生的音乐模式时:

Designing a generative music system for iOS, using OpenFrameworks, I'd need to provide a mode in which the user could listen the music produced by the application when:


  • 设备被锁定

  • 用户使用其他应用程序

般绽放,或闹钟一些应用程序,就像这一点,建议用户切换启用/禁用此功能。

Some applications like BLOOM, or alarm clock, works like that and propose to users a switch to enable/disable this feature.

对于任何提示?

推荐答案

播放背景声音

这起或连续(即使在应用程序是记录音频的应用
  在后台运行),可以注册,可以执行这些任务
  背景。您启用从背景模式的部分音频支持
  在你的X code项目功能选项卡。 (您也可以启用
  这种支持通过包括与音频UIBackgroundModes关键
  在应用程序的Info.plist文件值)。该发挥的音频内容应用
  背景必须发挥的音频内容,而不是沉默。

An app that plays or records audio continuously (even while the app is running in the background) can register to perform those tasks in the background. You enable audio support from the Background modes section of the Capabilities tab in your Xcode project. (You can also enable this support by including the UIBackgroundModes key with the audio value in your app’s Info.plist file.) Apps that play audio content in the background must play audible content and not silence.

<一个href=\"https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html\">Apple参考播放和录制背景声音

确保音频继续当屏幕锁定

有关启用/禁用此功能,我发现<一个href=\"https://developer.apple.com/library/ios/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/ConfiguringanAudioSession/ConfiguringanAudioSession.html#//apple_ref/doc/uid/TP40007875-CH2-SW23\">Activating并停用你的音频对话,我还没有尝试过自己,但它看起来像你所需要的。

For enabling/disabling this feature I found Activating and Deactivating Your Audio Session, I haven't tried it myself, but it looks like what you need.

这篇关于如何处理后台音频播放,而iOS设备被锁定,或者在另一个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆