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

后端 未结 11 867
误落风尘
误落风尘 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条回答
  •  旧时难觅i
    2020-12-04 12:45

    Swift 4 version:

    try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryAmbient)
    try? AVAudioSession.sharedInstance().setActive(true)
    

提交回复
热议问题