From f880ce85e981b2a9c4b870ab82cb56cb702b103d Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Fri, 31 Jul 2020 16:09:29 +0200 Subject: [PATCH] Added audioEnabled toggle --- swift/HelloLinphone/HelloLinphone/ContentView.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/swift/HelloLinphone/HelloLinphone/ContentView.swift b/swift/HelloLinphone/HelloLinphone/ContentView.swift index 47508fb..28cca67 100644 --- a/swift/HelloLinphone/HelloLinphone/ContentView.swift +++ b/swift/HelloLinphone/HelloLinphone/ContentView.swift @@ -53,6 +53,7 @@ class LinphoneTutorialContext : ObservableObject var mVideoDevices : [String] = [] var mUsedVideoDeviceId : Int = 0 + @Published var audioEnabled : Bool = true @Published var videoEnabled : Bool = false @Published var speakerEnabled : Bool = false @Published var callRunning : Bool = false @@ -166,7 +167,7 @@ class LinphoneTutorialContext : ObservableObject do { let callParams = try mCore.createCallParams(call: nil) callParams.videoEnabled = videoEnabled; - mCore.videoCaptureEnabled = callParams.videoEnabled; + callParams.audioEnabled = audioEnabled; if (!callRunning) { @@ -198,13 +199,14 @@ class LinphoneTutorialContext : ObservableObject { if (callRunning) { + callRunning = false if (mCall.state != Call.State.End){ // terminate the call print("Terminating the call...\n") do { try mCall.terminate() - callRunning = false } catch { + callRunning = true print(error) } } @@ -367,16 +369,18 @@ struct ContentView: View { } HStack { VStack(alignment: .leading) { + Toggle(isOn: $tutorialContext.audioEnabled) { + Text("Audio") + } Toggle(isOn: $tutorialContext.videoEnabled) { Text("Video") } HStack { Button(action: tutorialContext.changeVideoDevice) { - Text("Camera") + Text("Change camera") .font(.title) .foregroundColor(Color.white) - .frame(width: 120.0, height: 35.0) .background(Color.gray) } .padding(.bottom, 5.0)