twilio / video-quickstart-ios

Twilio Video Quickstart for iOS
https://www.twilio.com/docs/api/video
MIT License
457 stars 177 forks source link

Local Audio playback switches to receiver from LoudSpeaker when call connects #588

Open dericpr opened 3 years ago

dericpr commented 3 years ago

Description

Playback of local audio either stops or is directed to the receiver from the loudspeaker once a Peer to Peer Room connects. We have a metronome application in our video call and it needs to playback locally and mix with the audio from the incoming client as well.

I'm also seeing local audio fail completely after call is terminated. Is there some audio cleanup code I need to call to enable local audio after disconnecting the Twilio call?

Steps to Reproduce

  1. Start playback of local audio using AVAudioPlayer, playback comes from loud speaker
  2. Start a call and connect with a session
  3. Local audio switches from loud speakers to the receiver automatically and volume decreases.

Code

// TwilioVideo.audioDevice must be assigned prior to any audio or video track creation. let audioDevice = DefaultAudioDevice() TwilioVideoSDK.audioDevice = audioDevice
audioDevice.block = { do { try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .videoChat, options: [.mixWithOthers, .defaultToSpeaker])
try AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker) } catch { print(error) } }

    // Execute the block to apply settings on AVAudioSession
    audioDevice.block();

Expected Behavior

Local Audio playback should continue to come out the loudspeaker along with the call audio.

Actual Behavior

Local Audio playback switches to receiver and is barley audible over the call audio.

Reproduces How Often

100%

Versions

All relevant version information for the issue.

Video iOS SDK

4.2.0

Xcode

12.3

iOS Version

14.3

iOS Device

iPad Pro, iPad mini, iPad 8th gen