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

前端 未结 2 1634
野的像风
野的像风 2021-01-16 04:16

So I have an application and I want to keep it working even if the screen is turned off. Previously when I wanted to do that I used this hack/trick - I play a silent/empty s

相关标签:
2条回答
  • 2021-01-16 04:22

    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.

    0 讨论(0)
  • 2021-01-16 04:31

    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];
    
    0 讨论(0)
提交回复
热议问题