Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pax-k committed Apr 19, 2024
1 parent a2014e8 commit a080476
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions ios/ExpoAudioStreamModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ public class ExpoAudioStreamModule: Module {

private func configureAudioSession() {
do {
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(.playback, mode: .default, options: .defaultToSpeaker)
try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
try audioSession.overrideOutputAudioPort(.speaker)
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(.playAndRecord, mode: .default, options: [.allowBluetooth, .mixWithOthers])
try audioSession.setActive(true)
} catch {
print("Error configuring audio session: \(error)")
print("Error configuring audio session: \(error)")
}
}

Expand Down Expand Up @@ -210,7 +209,8 @@ 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.setPreferredInput(nil)
try? audioSession.overrideOutputAudioPort(headphonesConnected ? .none : .speaker)
print("updateAudioRoute: \(headphonesConnected)")
}

Expand Down Expand Up @@ -249,6 +249,7 @@ public class ExpoAudioStreamModule: Module {
OnCreate {
self.setupAudioEngine()
self.monitorAudioRouteChanges()
self.updateAudioRoute()
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mykin-ai/expo-audio-stream",
"version": "0.1.7",
"version": "0.1.8",
"description": "Expo Audio Stream module",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down

0 comments on commit a080476

Please sign in to comment.