Play sound with screen turned off / don't let iPhone go to sleep

风格不统一 提交于 2019-12-01 11:41:44

So the answer is to set session category. Some categories just turn off sound when the device is being locked. For me the best option was AVAudioSessionCategoryPlayback

[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];

I don't know about Apple fixing stuff, but in iOS 4 there are now official ways to continue doing things in the background which you should take advantage of.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!