Open History to see the last commit
1import { useReleasingSharedObjectWithLifecycle } from "expo";
2import { createAudioPlayer } from "expo-audio";
3import { disposeAudioPlayer } from "../../lib/audioSession";
4
5export function usePlaybackAudioPlayer(uri: string | null) {
6 // Keep the native ref alive until any pending activation and release finish.
7 return useReleasingSharedObjectWithLifecycle(
8 {
9 factory: () => createAudioPlayer(uri, { updateInterval: 500 }),
10 release: disposeAudioPlayer,
11 },
12 [uri],
13 );
14}