AVAudioSessionCategoryPlayAndRecord with Airplay

后端 未结 4 1395
我在风中等你
我在风中等你 2021-02-03 20:03

My app uses the microphone and outputs audio, so I am setting my Audio Session to the Play and Record Category, but this seems to disable Airplay. If I set the category to Play,

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-03 20:57

    You can try this code

    // Set AVAudioSession
    NSError *sessionError = nil;
    [[AVAudioSession sharedInstance] setDelegate:self];
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&sessionError];
    
    // Change the default output audio route
    UInt32 doChangeDefaultRoute = 1;
    AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,
      sizeof(doChangeDefaultRoute), &doChangeDefaultRoute);
    

提交回复
热议问题