kevin před 5 měsíci
rodič
revize
f2b78a0213

binární
NexilisLite/NexilisLite/Resource/Sound/pb_call_busy.mp3


+ 20 - 0
NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -127,6 +127,7 @@ public class Nexilis: NSObject {
     
     static var ringtonePlayer: AVAudioPlayer?
     static var ringbacktonePlayer: AVAudioPlayer?
+    static var busyPlayer: AVAudioPlayer?
     static var sharedAudioPlayer: AVAudioPlayer?
     
     private func createDelegate() {
@@ -341,6 +342,25 @@ public class Nexilis: NSObject {
         ringbacktonePlayer?.stop()
     }
     
+    public static func playBusyCall() {
+        var busyPath = Bundle.resourceBundle(for: Nexilis.self).url(forResource: "pb_call_busy", withExtension: "mp3")
+        if busyPath == nil {
+            busyPath = Bundle.resourcesMediaBundle(for: Nexilis.self).url(forResource: "pb_call_busy", withExtension: "mp3")
+        }
+        do {
+            busyPlayer = try AVAudioPlayer(contentsOf:busyPath!)
+            busyPlayer?.numberOfLoops = 1
+            busyPlayer?.prepareToPlay()
+            busyPlayer?.play()
+        } catch {
+            
+        }
+    }
+    
+    public static func stopBusyCall() {
+        busyPlayer?.stop()
+    }
+    
     public static func addFB(viewController: UIViewController, fromMAB: Bool) {
         if let keyWindow = UIApplication.shared.windows.first(where: { $0.isKeyWindow }) {
             keyWindow.addSubview(floatingButton)

+ 5 - 1
NexilisLite/NexilisLite/Source/View/Call/QmeraAudioViewController.swift

@@ -1079,7 +1079,11 @@ class QmeraAudioViewController: UIViewController {
                     DispatchQueue.main.async {
                         self.status.text = "Busy..."
                         self.end.isEnabled = false
-                        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
+                        if self.isOutgoing {
+                            Nexilis.playBusyCall()   
+                        }
+                        DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
+                            Nexilis.stopBusyCall()
                             self.didEnd(sender: false)
                         }
                     }

+ 5 - 1
NexilisLite/NexilisLite/Source/View/Call/QmeraVideoViewController.swift

@@ -1527,7 +1527,11 @@ class QmeraVideoViewController: UIViewController {
                 }
             }
             if (self.dataPerson.count == 1) {
-                DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
+                DispatchQueue.main.async {
+                    Nexilis.playBusyCall()
+                }
+                DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
+                    Nexilis.stopBusyCall()
                     self.endAllCall()
                     if self.isInisiator && onGoingCC.isEmpty && !self.isPresent {
                         self.navigationController?.popViewController(animated: true)