Only one camera works at a time with following code. I have read some old articles saying this is not possible so I want to ask if it's still not possible because my phone's camera application can do this so I know there's some way.
import {
useCameraDevices,
Camera,
useCameraDevice,
useCameraPermission,
} from "react-native-vision-camera";
import { View, Button, Text } from "react-native";
import { useEffect, useState } from "react";
const DualCameraScreen = () => {
const device1 = useCameraDevice("front");
const device2 = useCameraDevice("back");
const { hasPermission, requestPermission } = useCameraPermission();
const [isRecording, setIsRecording] = useState(false);
if (!hasPermission) {
requestPermission();
}
const startRecording = async () => {
setIsRecording(true);
};
return (
<View style={{ flex: 1 }}>
{device1 && device2 && (
<View
style={{ flex: 1, flexDirection: "column", backgroundColor: "green" }}
>
<Camera
style={{ flex: 1 / 3, width: "100%" }}
device={device1}
isActive={true}
video={true}
/>
<Camera
style={{ flex: 1 / 3, width: "100%" }}
device={device2}
isActive={true}
/>
</View>
)}
</View>
);
};
export default DualCameraScreen;
Only one camera works at a time with following code. I have read some old articles saying this is not possible so I want to ask if it's still not possible because my phone's camera application can do this so I know there's some way.
import {
useCameraDevices,
Camera,
useCameraDevice,
useCameraPermission,
} from "react-native-vision-camera";
import { View, Button, Text } from "react-native";
import { useEffect, useState } from "react";
const DualCameraScreen = () => {
const device1 = useCameraDevice("front");
const device2 = useCameraDevice("back");
const { hasPermission, requestPermission } = useCameraPermission();
const [isRecording, setIsRecording] = useState(false);
if (!hasPermission) {
requestPermission();
}
const startRecording = async () => {
setIsRecording(true);
};
return (
<View style={{ flex: 1 }}>
{device1 && device2 && (
<View
style={{ flex: 1, flexDirection: "column", backgroundColor: "green" }}
>
<Camera
style={{ flex: 1 / 3, width: "100%" }}
device={device1}
isActive={true}
video={true}
/>
<Camera
style={{ flex: 1 / 3, width: "100%" }}
device={device2}
isActive={true}
/>
</View>
)}
</View>
);
};
export default DualCameraScreen;
Share
Improve this question
asked Feb 2 at 12:26
Jazzel MehmoodJazzel Mehmood
51 silver badge4 bronze badges
1 Answer
Reset to default 0Camera 2 is missing its
video={true}