Skip to content

Commit

Permalink
force overrideOutputAudioPort
Browse files Browse the repository at this point in the history
  • Loading branch information
pax-k committed Apr 19, 2024
1 parent 3f5c85f commit 4ef8e73
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ios/ExpoAudioStreamModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}
Expand Down Expand Up @@ -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)")
}

Expand Down

0 comments on commit 4ef8e73

Please sign in to comment.