with vision camera
import React, { useEffect, useState } from 'react';
import { View, StyleSheet } from 'react-native';
import { Camera, useCameraDevices } from 'react-native-vision-camera';
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#000',
},
});
function VideoScreen() {
const { cameraDevices, getCameraPermissions, requestCameraPermission } = useCameraDevices();
const [cameraActive, setCameraActive] = useState(false);
// Check camera permission and request if not granted
useEffect(() => {
getCameraPermissions().then((permissions) => {
if (!permissions.cameraPermission) {
requestCameraPermission();
}
});
}, []);
return (
<View style={styles.container}>
{cameraDevices.map((device) => (
<Camera
key={device.id}
device={device}
style={{ flex: 1 }}
isActive={cameraActive && device.isActive}
enableFrameRate={true}
frameRate={30}
audio={false}
video={{
preset: '1280x720',
uri: 'http://192.168.1.16',
contentType: 'application/octet-stream',
}}
/>
))}
</View>
);
}
export default VideoScreen;
Comments
Post a Comment