|
@@ -259,7 +259,7 @@ public class Nexilis: NSObject {
|
|
|
Nexilis.dispatch = DispatchGroup()
|
|
|
Nexilis.dispatch?.enter()
|
|
|
|
|
|
- try API.initConnection(bSwitchIP: true, sAPIK: Nexilis.sAPIKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: f_pin, sStartWH: "08:00")
|
|
|
+ try API.switchUser(cbiI: Callback(), sUserID: f_pin)
|
|
|
|
|
|
// wait until connection true
|
|
|
Nexilis.dispatch?.wait()
|
|
@@ -425,32 +425,8 @@ public class Nexilis: NSObject {
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
- public static func startAudio(nMode: Int!, bSpeakerOn: Bool!) {
|
|
|
-
|
|
|
- let nSessionMode = nMode
|
|
|
- do {
|
|
|
- let avAudioSession = AVAudioSession.sharedInstance()
|
|
|
- try avAudioSession.setInputGain(1.0)
|
|
|
-// if (bSpeakerOn) {
|
|
|
-// try avAudioSession.setCategory(.playAndRecord, mode: (nSessionMode == 1 ? .voiceChat : .videoChat), options: [.defaultToSpeaker, .duckOthers, .allowBluetooth])
|
|
|
-// } else {
|
|
|
-// try avAudioSession.setCategory(.playAndRecord, mode: (nSessionMode == 1 ? .voiceChat : .videoChat), options: [.duckOthers, .allowBluetooth])
|
|
|
-// }
|
|
|
- try avAudioSession.setCategory(.playAndRecord, mode: (nSessionMode == 1 ? .voiceChat : .default), options: [.defaultToSpeaker, .duckOthers, .allowBluetooth])
|
|
|
- if (bSpeakerOn) {
|
|
|
- API.adjustVolume(fValue: 10.0)
|
|
|
- } else {
|
|
|
- API.adjustVolume(fValue: 0.3)
|
|
|
- }
|
|
|
- try avAudioSession.setActive(true, options: .notifyOthersOnDeactivation)
|
|
|
- } catch {
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public static func turnSpeakerOn(bSpeakerOn: Bool!) {
|
|
|
// API.pauseAudio()
|
|
|
-// ViewController.stopAudio()
|
|
|
-// ViewController.startAudio(nMode: 0, bSpeakerOn: bSpeakerOn)
|
|
|
// API.resumeAudio(bSpeakerOn: bSpeakerOn)
|
|
|
if (bSpeakerOn) {
|
|
|
API.adjustVolume(fValue: 10.0)
|
|
@@ -458,15 +434,6 @@ public class Nexilis: NSObject {
|
|
|
API.adjustVolume(fValue: 0.3)
|
|
|
}
|
|
|
}
|
|
|
- public static func stopAudio() {
|
|
|
- do {
|
|
|
- try AVAudioSession.sharedInstance().setCategory(.ambient)
|
|
|
- try AVAudioSession.sharedInstance().setMode(.default)
|
|
|
- try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)
|
|
|
- }catch{
|
|
|
- print(error)
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
public static func muteMicrophone(isMute: Bool!){
|
|
|
do {
|
|
@@ -1604,7 +1571,6 @@ extension Nexilis: CallDelegate {
|
|
|
let onGoingCC = UserDefaults.standard.string(forKey: "onGoingCC") ?? ""
|
|
|
let deviceId = message.split(separator: ",")[0]
|
|
|
if myData?.offline_mode == "1" || self.stateUnfriend == deviceId {
|
|
|
- Nexilis.startAudio(nMode: 1, bSpeakerOn: false)
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
|
|
|
API.terminateCall(sParty: nil)
|
|
|
})
|