How can I allow background music to continue playing while my app still plays its sounds while using Swift

后端 未结 11 873
误落风尘
误落风尘 2020-12-04 11:57

I created an app and I am attempting to allow the user to continue to listen to their music while playing my game, but whenever they hit \"play\" and the ingame sounds occur

11条回答
  •  囚心锁ツ
    2020-12-04 12:49

    lchamp's solution worked perfectly for me, adapted for Objective-C:

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
    [[AVAudioSession sharedInstance] setActive:YES error:nil];
    

提交回复
热议问题