background audio for video react-native-video

Viewed 6711

I am unable to get react-native-video to play mp4 files in the background, It will play mp3s and audio files but it refuses to continue playing the video. I have set the background modes in xcode to on with the audio, airplay and picture in picture selected as well as passing these props in as well

playInBackground={true}
playWhenInactive={true}
ignoreSilentSwitch={'ignore'}

is there additional configuration required when its a video and not just audio?

1 Answers

Try the code below:

<Video
    source={{uri: 'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4'}}
    style={{ width: 400, height: 400}}
    muted={false}
    repeat={false}
    resizeMode={"cover"}
    volume={1.0}
    rate={1.0}
    ignoreSilentSwitch={"ignore"}
    playWhenInactive={true}
    playInBackground={true}
  />

Run your project from Xcode after doing the step below not just from React-Native packager.

Set the Capabilities in Xcode:

enter image description here

Related