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?
Let's move to the important part: placing the video in the background position. Let's define the styles. // We use StyleSheet from react-native so don't forget to import it //import {StyleSheet} from "react-native"; const { height } = Dimensions. get("window"); const styles = StyleSheet.
To allow background audio playback on iOS, you need to activate the 'Audio, Airplay and Picture in Picture' background mode in Xcode. Without activating it, the audio will only play when the app is in the foreground.
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
:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With