Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switching off a speaker on a voice call using TwilioVideo #634

Open
Irynavb opened this issue Oct 13, 2021 · 1 comment
Open

switching off a speaker on a voice call using TwilioVideo #634

Irynavb opened this issue Oct 13, 2021 · 1 comment

Comments

@Irynavb
Copy link

Irynavb commented Oct 13, 2021

Hello,

I'm having an issue switching off a speaker on a voice call using TwilioVideo (for an iOS application). As the audio routes default to the speaker, I am overriding it while configuring an audio session using the reference from the issues #307 and #379. However, using the following code does not seem to achieve the preferred result.

let audioDevice = DefaultAudioDevice()
    TwilioVideoSDK.audioDevice = audioDevice
     
    audioDevice.block = {
      DefaultAudioDevice.DefaultAVAudioSessionConfigurationBlock()
     
      do {
         
        let session = AVAudioSession.sharedInstance()
        print("set audio session")
        try session.setCategory(.playAndRecord, mode: .voiceChat)
        try session.overrideOutputAudioPort(.none)
         
     // tried adding the lines with an if-statement below as well as overriding the input above to `.none`
        if isSpeaker {
          try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)
        }
        try session.setActive(true, options: .notifyOthersOnDeactivation)
      } catch let error {
        print("Error while configuring audio session: \(error)")
      }
       
    }
    audioDevice.block()
  }
  

Thank you in advance for your help!

@SrmNarola
Copy link

Hi @Irynavb Would you please share DefaultAudioDevice() class code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants