I need to implement iPhone speaker (ear and bottom) change during audio call (using TwilioVideo SDK for connection) Mine code:
let audioSession = AVAudioSession.sharedInstance()
do {
if isSpeaker == false {
try audioSession.overrideOutputAudioPort(.speaker)
isSpeaker = true
} else {
try audioSession.overrideOutputAudioPort(.none)
isSpeaker = false
}
try audioSession.setActive(true)
} catch {
handleError(error.localizedDescription)
}
It works without any exceptions, but don't change audio output speaker
Twilio developer evangelist here.
You should not use
AVAudioSessionAPIs directly with Twilio Video. Instead, you should use theTVIAudioControllerand set theaudioOutputproperty to one of the options enumerated inTVIAudioOutput.Let me know if that helps.