Explorar o código

Fix for 'repairing' audio, it sometimes was unable to speak

Jonas Björkert %!s(int64=2) %!d(string=hai) anos
pai
achega
ce5e854460
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      LoopFollow/Controllers/Alarms.swift

+ 8 - 0
LoopFollow/Controllers/Alarms.swift

@@ -977,6 +977,14 @@ extension MainViewController {
     // Speaks the current blood glucose value and the change from the previous value.
     // Repeated calls to the function within 30 seconds are prevented.
     func speakBG(currentValue: Int, previousValue: Int) {
+        let audioSession = AVAudioSession.sharedInstance()
+        do {
+            try audioSession.setCategory(.playback, mode: .default)
+            try audioSession.setActive(true)
+        } catch {
+            print("Failed to set up audio session: \(error)")
+        }
+        
         // Get the current time
         let currentTime = Date()