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

前端 未结 2 1636
野的像风
野的像风 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: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];
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题