From d9eb1ea5486e987e44e72ce6266df69464d512a8 Mon Sep 17 00:00:00 2001 From: Alexander Demchuk Date: Tue, 7 Jan 2025 17:43:28 +0100 Subject: [PATCH] fix: fixed bluetooth recording for simultaneous (#7) --- README.md | 2 +- example/App.tsx | 21 ++++- example/ios/Podfile.lock | 8 +- .../project.pbxproj | 34 +++++--- ios/AudioController.swift | 2 +- ios/AudioSessionManager.swift | 2 +- ios/ExpoPlayAudioStreamModule.swift | 44 ++++++---- ios/Microphone.swift | 18 ++--- ios/SoundPlayer.swift | 80 +++++++++++++++++-- src/events.ts | 3 + 10 files changed, 158 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index c52915e..aa19480 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ const audioSubscription = ExpoPlayAudioStream.subscribeToAudioEvents(async (even // audioSubscription.remove(); ``` -### Simultaneous Recording and Playback +### Simultaneous Recording and Playback (⚠️ IOS only for now) ```javascript import { ExpoPlayAudioStream } from 'expo-audio-stream'; diff --git a/example/App.tsx b/example/App.tsx index 0727248..e54fda8 100644 --- a/example/App.tsx +++ b/example/App.tsx @@ -28,6 +28,21 @@ export default function App() { console.log(audio.data.slice(0, 100)); }; + const playEventsListenerSubscriptionRef = useRef(undefined); + + useEffect(() => { + playEventsListenerSubscriptionRef.current = ExpoPlayAudioStream.subscribeToSoundChunkPlayed(async (event) => { + console.log(event); + }); + + return () => { + if (playEventsListenerSubscriptionRef.current) { + playEventsListenerSubscriptionRef.current.remove(); + playEventsListenerSubscriptionRef.current = undefined; + } + } + }, []); + return ( hi @@ -51,7 +66,7 @@ export default function App() {