ios 边录音边放_ios中同时录音和播放

通远
2023-12-01

SetRecordPlayAtSameTime_Func

// 需添加: AudioToolBox.framework

#import

#import

#import

// 设置录音和播放同时进行、且扬声器播放

-(void)SetRecordPlayAtSameTime_Func

{

// 同时录音和播放

UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;

AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);

// 扬声器播放

UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;

AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOverride), &audioRouteOverride);

AudioSessionSetActive(true);

/*

AVAudioSession* session = [AVAudioSession sharedInstance];

[session setCategory:AVAudioSessionCategoryPlayback error:nil];

[session setActive: YES error:nil];

*/

}

 类似资料: