react-native-audio-recorder-player icon indicating copy to clipboard operation
react-native-audio-recorder-player copied to clipboard

How to disable background playing?

Open KnowledgeWanderer opened this issue 3 years ago • 1 comments

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!

KnowledgeWanderer avatar Oct 18 '21 13:10 KnowledgeWanderer

You may try to use AppState and stop player when it is on background

hyochan avatar Nov 14 '21 12:11 hyochan