Skip to content

Commit

Permalink
Merge pull request #108 from team-telnyx/IS/Fix/SpeakerToggle
Browse files Browse the repository at this point in the history
Speaker Toggle Fix
  • Loading branch information
isaacakakpo1 authored Oct 16, 2023
2 parents 2189b87 + b0d0d0f commit fa7be01
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ extension ViewController : VoIPDelegate {
case .CONNECTING:
break
case .RINGING:
self.setCurrentAudioOutput()
break
case .NEW:
break
Expand All @@ -106,6 +107,7 @@ extension ViewController : VoIPDelegate {
if(self.isCallOutGoing()){
self.appDelegate.executeOutGoingCall()
}
self.setCurrentAudioOutput()
break
case .DONE:
self.resetCallStates()
Expand All @@ -117,6 +119,12 @@ extension ViewController : VoIPDelegate {
}
}

func setCurrentAudioOutput(){
if(self.isSpeakerActive){
self.telnyxClient?.setSpeaker()
}
}

func executeCall(callUUID: UUID, completionHandler: @escaping (Call?) -> Void) {
do {
guard let callerName = self.settingsView.callerIdNameLabel.text,
Expand Down
2 changes: 2 additions & 0 deletions TelnyxWebRTCDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ViewController: UIViewController {
var userDefaults: UserDefaults = UserDefaults.init()
var telnyxClient: TxClient?
var incomingCall: Bool = false
var isSpeakerActive : Bool = false

var loadingView: UIAlertController?

Expand Down Expand Up @@ -245,6 +246,7 @@ extension ViewController : UICallScreenDelegate {
}

func onToggleSpeaker(isSpeakerActive: Bool) {
self.isSpeakerActive = isSpeakerActive
if (isSpeakerActive) {
self.telnyxClient?.setSpeaker()
} else {
Expand Down

0 comments on commit fa7be01

Please sign in to comment.