Play and record video while playing some background music

后端 未结 1 1213
借酒劲吻你
借酒劲吻你 2020-12-25 10:26

I looked in several forums and they all couldn\'t deliver a satisfying answer.

My wish is to be able to play and record video while playing music at the background.

相关标签:
1条回答
  • 2020-12-25 10:36

    When you override the seesion category with *kAudioSessionProperty_OverrideCategoryMixWithOthers* it uses the smaller speaker on the top side of the device (besides the frontend camera). To use the regular speaker as the output device, you should instead redirect the output route of your audio session. The following is the code snippet of achieving this

    UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
    
    AudioSessionSetProperty ( 
        kAudioSessionProperty_OverrideAudioRoute,                         
        sizeof (audioRouteOverride),                                      
        &audioRouteOverride                                               
    ); 
    

    Replace this code with your above and it will work. You can further refer Redirect Output Audio on apple developer portal.

    0 讨论(0)
提交回复
热议问题