From 4ef8e73be0e8eb964958d370aca5f9a7fb295424 Mon Sep 17 00:00:00 2001 From: pax-k Date: Fri, 19 Apr 2024 12:34:35 +0300 Subject: [PATCH] force overrideOutputAudioPort --- ios/ExpoAudioStreamModule.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ios/ExpoAudioStreamModule.swift b/ios/ExpoAudioStreamModule.swift index 3f276b6..1340a51 100644 --- a/ios/ExpoAudioStreamModule.swift +++ b/ios/ExpoAudioStreamModule.swift @@ -31,6 +31,7 @@ public class ExpoAudioStreamModule: Module { let audioSession = AVAudioSession.sharedInstance() try audioSession.setCategory(.playAndRecord, mode: .voicePrompt, options: [.duckOthers ,.defaultToSpeaker, .allowBluetooth, .allowBluetoothA2DP, .allowAirPlay]) try audioSession.setActive(true, options: .notifyOthersOnDeactivation) + try audioSession.overrideOutputAudioPort(.speaker) } catch { print("Error configuring audio session: \(error)") } @@ -209,7 +210,7 @@ public class ExpoAudioStreamModule: Module { private func updateAudioRoute() { let audioSession = AVAudioSession.sharedInstance() let headphonesConnected = audioSession.currentRoute.outputs.contains { $0.portType == .headphones || $0.portType == .bluetoothA2DP } - try? audioSession.overrideOutputAudioPort(headphonesConnected ? .none : .speaker) + // try? audioSession.overrideOutputAudioPort(headphonesConnected ? .none : .speaker) print("updateAudioRoute: \(headphonesConnected)") }