音频后台播放

1,开启后台任务,让程序保持运行

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [application beginBackgroundTaskWithExpirationHandler:nil];
}

2,在info.plist添加Required background modes,为其添加App plays audio or streams audio/video using AirPlay。
3,设置音频回话类型

AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategorySoloAmbient error:nil];
[session setActive:YES error:nil];

你可能感兴趣的:(app)