Search code examples
react-nativespotifyaudio-playerreact-native-video

Spotify Stops when I open my react native app


When I first open my app Spotify music stops after that when I go back and turn on the music and come back to the my app, it works fine. I am using react-native video library for Splash screen and video doesn't have audio and also muted by component props. Is there any way to keep music alive when I open my app?


Solution

  • Recently i face this problem,

    i think you are using

    1. react-native-video
    2. react-native-camera

    These 2 libraries pause the playback music

    so you need to follow these steps to resolve this problem,

    react-native-video

    ignoreSilentSwitch Controls the iOS silent switch behavior

    1. ignoreSilentSwitch: "obey" - Don't play audio if the silent switch is set

    2. mixWithOthers: "mix" - Audio from this video mixes with audio from other apps.

    code Snippet:

     <Video 
       ....
        ignoreSilentSwitch="obey"
        mixWithOthers={'mix'}
       ....
     />
    

    react-native-camera

     <RNCamera
       .....
        captureAudio={false}
       .....
    
     />