From 0e863b59e25e00097acf0c0ae16cba0a02601ea5 Mon Sep 17 00:00:00 2001 From: pax-k Date: Fri, 19 Apr 2024 11:27:25 +0300 Subject: [PATCH] wip --- ios/ExpoAudioStreamModule.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ios/ExpoAudioStreamModule.swift b/ios/ExpoAudioStreamModule.swift index c009058..3f276b6 100644 --- a/ios/ExpoAudioStreamModule.swift +++ b/ios/ExpoAudioStreamModule.swift @@ -29,7 +29,7 @@ public class ExpoAudioStreamModule: Module { private func configureAudioSession() { do { let audioSession = AVAudioSession.sharedInstance() - try audioSession.setCategory(.playback, mode: .voicePrompt, options: [.duckOthers ,.defaultToSpeaker, .allowBluetooth, .allowBluetoothA2DP, .allowAirPlay]) + try audioSession.setCategory(.playAndRecord, mode: .voicePrompt, options: [.duckOthers ,.defaultToSpeaker, .allowBluetooth, .allowBluetoothA2DP, .allowAirPlay]) try audioSession.setActive(true, options: .notifyOthersOnDeactivation) } catch { print("Error configuring audio session: \(error)") @@ -185,8 +185,9 @@ public class ExpoAudioStreamModule: Module { } private func monitorAudioRouteChanges() { - NotificationCenter.default.removeObserver(self) - NotificationCenter.default.addObserver(self, selector: #selector(handleAudioSessionRouteChange), name: AVAudioSession.routeChangeNotification, object: nil) + NotificationCenter.default.addObserver(forName: AVAudioSession.routeChangeNotification, object: AVAudioSession.sharedInstance(), queue: nil) { [weak self] notification in + self?.handleAudioSessionRouteChange(notification: notification) + } } @objc private func handleAudioSessionRouteChange(notification: Notification) {