react-native-audio-recorder-player
react-native-audio-recorder-player copied to clipboard
How to disable background playing?
Hi, I'm trying to effectively disable backgorund playing. So when I navigate, the player just stops.
What's the way I should approach this? I was thinking of maybe creating a big new AudioRecorderPlayer() in index and relate to that instance of the module or what should I do?
I tried something like this
<Stack.Screen name="Home" options={{
headerShown: true,
title: '',
headerStyle: {
backgroundColor: '#212529'
},
headerLeft: () => (
<HeaderBackButton
label=""
onPress={() => {
audioRecorderPlayer.stopPlayer().catch((e) =>
console.log(`error while stopping player, ${e}`)
);
navigate('Home')
}}
pressColorAndroid="#00000000"
backImage={(props) => <Image source={require("../../graphics/medinav_logo_no_bg.png")}
style={{ width: 100, height: 40 }}/>}
/>
),
it doesn't work!
You may try to use AppState and stop player when it is on background