Мне нужно реализовать собственный аудиодрайвер с настройкой AVAudioSession
var audioOptions: UInt {
if isSpeaker {
return AVAudioSessionCategoryOptions.defaultToSpeaker.rawValue |
AVAudioSessionCategoryOptions.mixWithOthers.rawValue |
AVAudioSessionCategoryOptions.allowBluetooth.rawValue |
AVAudioSessionCategoryOptions.allowAirPlay.rawValue
} else {
return AVAudioSessionCategoryOptions.mixWithOthers.rawValue |
AVAudioSessionCategoryOptions.allowBluetooth.rawValue |
AVAudioSessionCategoryOptions.allowAirPlay.rawValue |
AVAudioSessionCategoryOptions.duckOthers.rawValue
}
}
if isSpeaker {
try session.setCategory(AVAudioSessionCategoryPlayAndRecord, mode: AVAudioSessionModeVoiceChat, options: AVAudioSessionCategoryOptions(rawValue: audioOptions))
} else {
try session.setCategory(AVAudioSessionCategoryPlayAndRecord, mode: AVAudioSessionModeVoiceChat, options: AVAudioSessionCategoryOptions(rawValue: audioOptions))
}