I am trying to implement react-native-vision-camera
into my React Native app, and it works perfectly as expected on iOS, but on Android it refuses to work properly.
On Android, I am greeted with the following error...
[session/camera-not-ready] The Camera is not ready yet! Wait for the onInitialized() callback!
From what I've seen, this error occurs when the is called before permissions are verified, which is not the case in my app. Consider the following...
// Camera Permission State
const [cameraPerm, setCameraPerm] = useState(false)
// Checks Mic and Video Permissions as soon as page loads
useEffect(() => {
checkPermissions();
}, []);
// Called in a useEffect to gain permissions
const checkPermissions = async () => {
// Request Permissions on component load
await Camera.requestCameraPermission();
await Camera.requestMicrophonePermission();
await requestPermission()
const cameraPermission = await Camera.getCameraPermissionStatus();
setCameraPerm(cameraPermission)
const microphonePermission = await Camera.getMicrophonePermissionStatus();
};
// Renders The Camera, if permissed and not done recording
function renderCameraScreen(){
// No permissions
if (device == null) return <View style={{backgroundColor: 'black'}}/>;
// Video Recorded
if (recorded){
return(
<View>
<Text style={{...FONTS.Title, textAlign: 'center', marginTop: 100}}>
Video Recorded
</Text>
</View>
)
}
if (!cameraPerm){
return(
<View>
<Text style={{...FONTS.Title, textAlign: 'center', marginTop: 100}}>
Please enable video permissions from your settings to access the camera
</Text>
</View>
)
}
return (
<View style={{backgroundColor: 'black', height: maxHeight * 0.70,}}>
<Camera
style={StyleSheet.absoluteFill}
device={device}
isActive={true}
video={true}
audio={true}
ref={camera}
/>
<View style={{alignSelf: 'center', marginTop: maxHeight * 0.65}}>
{renderRecordButton()}
</View>
</View>
);
};
Considering this, I do not know why I am getting this error. Truthfully, I've also been unable to find any mention of onInitialized()
in any documentation, so I am unsure how I would even utilize that function, as well as where.