|
@@ -18,7 +18,7 @@ import NotificationBannerSwift
|
|
|
public class Nexilis: NSObject {
|
|
|
public static var sAPIKey = ""
|
|
|
|
|
|
- static let ADDRESS = ADDRESS_RELEASE
|
|
|
+ public static let ADDRESS = ADDRESS_RELEASE
|
|
|
|
|
|
static let ADDRESS_33 = "192.168.0.33"
|
|
|
|
|
@@ -52,6 +52,8 @@ public class Nexilis: NSObject {
|
|
|
|
|
|
public static var openBroadcast = false
|
|
|
|
|
|
+ public static var loadingAlert = UIAlertController()
|
|
|
+
|
|
|
private func createDelegate() {
|
|
|
print("createDelegate...")
|
|
|
callDelegate = self
|
|
@@ -396,56 +398,36 @@ public class Nexilis: NSObject {
|
|
|
|
|
|
public static func startAudio(nMode: Int!, bSpeakerOn: Bool!) {
|
|
|
|
|
|
- let xSessionMode = nMode == 0 ? nSessionMode : nMode
|
|
|
+ let nSessionMode = nMode
|
|
|
do {
|
|
|
- if ("iPhone 6" == UIDevice.current.modelName) {
|
|
|
- try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: .duckOthers)
|
|
|
- if (xSessionMode == 1) {
|
|
|
- try AVAudioSession.sharedInstance().setMode(.voiceChat)
|
|
|
- } else if (xSessionMode == 2) {
|
|
|
- try AVAudioSession.sharedInstance().setMode(.voiceChat)
|
|
|
- // try avAudioSession.setMode(AVAudioSessionModeVideoChat)
|
|
|
- }
|
|
|
- if (bSpeakerOn) {
|
|
|
- try AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker)
|
|
|
- } else {
|
|
|
- try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)
|
|
|
- }
|
|
|
+ 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 {
|
|
|
- if (bSpeakerOn) {
|
|
|
- try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: .defaultToSpeaker)
|
|
|
- } else {
|
|
|
- try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: .duckOthers)
|
|
|
- }
|
|
|
- if (xSessionMode == 1) {
|
|
|
- try AVAudioSession.sharedInstance().setMode(.voiceChat)
|
|
|
- } else if (xSessionMode == 2) {
|
|
|
- try AVAudioSession.sharedInstance().setMode(.voiceChat)
|
|
|
- }
|
|
|
+ API.adjustVolume(fValue: 0.3)
|
|
|
}
|
|
|
- try AVAudioSession.sharedInstance().setActive(true)
|
|
|
- } catch {}
|
|
|
- nSessionMode = xSessionMode
|
|
|
+ try avAudioSession.setActive(true, options: .notifyOthersOnDeactivation)
|
|
|
+ } catch {
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static func turnSpeakerOn(bSpeakerOn: Bool!) {
|
|
|
- do{
|
|
|
- if ("iPhone 6" == UIDevice.current.modelName) {
|
|
|
- if (bSpeakerOn) {
|
|
|
- try AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker)
|
|
|
- } else {
|
|
|
- try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)
|
|
|
- }
|
|
|
- return
|
|
|
- }
|
|
|
- }catch{
|
|
|
- print(error)
|
|
|
+// API.pauseAudio()
|
|
|
+// ViewController.stopAudio()
|
|
|
+// ViewController.startAudio(nMode: 0, bSpeakerOn: bSpeakerOn)
|
|
|
+// API.resumeAudio(bSpeakerOn: bSpeakerOn)
|
|
|
+ if (bSpeakerOn) {
|
|
|
+ API.adjustVolume(fValue: 10.0)
|
|
|
+ } else {
|
|
|
+ API.adjustVolume(fValue: 0.3)
|
|
|
}
|
|
|
-
|
|
|
- API.pauseAudio()
|
|
|
- stopAudio()
|
|
|
- startAudio(nMode: 0, bSpeakerOn: bSpeakerOn)
|
|
|
- API.resumeAudio(bSpeakerOn: bSpeakerOn)
|
|
|
}
|
|
|
public static func stopAudio() {
|
|
|
do {
|
|
@@ -484,6 +466,8 @@ public class Nexilis: NSObject {
|
|
|
fb.bniBookingTap()
|
|
|
} else if id == "openHistoryCC" {
|
|
|
fb.historyBroadcastTap()
|
|
|
+ } else if index == 7 {
|
|
|
+ fb.openCustomURL(url: id)
|
|
|
} else {
|
|
|
let idButton = UIButton()
|
|
|
idButton.restorationIdentifier = id
|
|
@@ -491,6 +475,22 @@ public class Nexilis: NSObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static func showLoader() {
|
|
|
+ loadingAlert = UIAlertController(title: nil, message: "Please wait...".localized(), preferredStyle: .alert)
|
|
|
+
|
|
|
+ let loadingIndicator = UIActivityIndicatorView(frame: CGRect(x: 10, y: 5, width: 50, height: 50))
|
|
|
+ loadingIndicator.hidesWhenStopped = true
|
|
|
+ loadingIndicator.style = .medium
|
|
|
+ loadingIndicator.startAnimating()
|
|
|
+
|
|
|
+ loadingAlert.view.addSubview(loadingIndicator)
|
|
|
+ UIApplication.shared.visibleViewController?.present(loadingAlert, animated: true, completion: nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ public static func hideLoader() {
|
|
|
+ loadingAlert.dismiss(animated: true)
|
|
|
+ }
|
|
|
+
|
|
|
private static var groupWait = DispatchGroup()
|
|
|
|
|
|
private static var waitQueue = [String: TMessage]()
|
|
@@ -1299,6 +1299,17 @@ extension Nexilis: CallDelegate {
|
|
|
if !onGoingCC.isEmpty {
|
|
|
videoController.isAutoAccept = true
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + isShowAlert!, execute: {
|
|
|
+ if UIApplication.shared.visibleViewController is UIAlertController {
|
|
|
+ let vc = UIApplication.shared.visibleViewController as! UIAlertController
|
|
|
+ vc.dismiss(animated: true, completion: {
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
|
|
|
+ } else {
|
|
|
+ UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: nil)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
|
|
|
} else {
|
|
@@ -1306,6 +1317,17 @@ extension Nexilis: CallDelegate {
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
+ if UIApplication.shared.visibleViewController is UIAlertController {
|
|
|
+ let vc = UIApplication.shared.visibleViewController as! UIAlertController
|
|
|
+ vc.dismiss(animated: true, completion: {
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
|
|
|
+ } else {
|
|
|
+ UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: nil)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
|
|
|
} else {
|
|
@@ -2590,6 +2612,11 @@ extension Nexilis: MessageDelegate {
|
|
|
vc.navigationController?.popViewController(animated: true)
|
|
|
openEditor()
|
|
|
}
|
|
|
+ } else if UIApplication.shared.visibleViewController is UIAlertController {
|
|
|
+ let vc = UIApplication.shared.visibleViewController as! UIAlertController
|
|
|
+ vc.dismiss(animated: true, completion: {
|
|
|
+ openEditor()
|
|
|
+ })
|
|
|
} else {
|
|
|
openEditor()
|
|
|
}
|
|
@@ -2656,6 +2683,11 @@ extension Nexilis: MessageDelegate {
|
|
|
vc.navigationController?.popViewController(animated: true)
|
|
|
openEditor()
|
|
|
}
|
|
|
+ } else if UIApplication.shared.visibleViewController is UIAlertController {
|
|
|
+ let vc = UIApplication.shared.visibleViewController as! UIAlertController
|
|
|
+ vc.dismiss(animated: true, completion: {
|
|
|
+ openEditor()
|
|
|
+ })
|
|
|
} else {
|
|
|
openEditor()
|
|
|
}
|