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() {