Closed favaztechcurve closed 8 months ago
Same issue for me. I just downgraded to 3.6.16 and everything works fine
@AlexDef can you absolutely confirm that in 3.6.17 you get null
, and in 3.6.16 it works properly? Nothing of the getCameraDevices
logic has changed so this is very weird to me.
Yes I can confirm it, just downgrade and the useCameraDevice function start to work again. The bug was only on Android and not on every device, of course...
Wait - I just noticed that you are using useCameraDevices()
. In V3, useCameraDevices()
does something else. You should use the new useCameraDevice(...)
(no s
) hook instead. Read the docs for more info.
@mrousavy actually i was using 2.16.0 before and its works fine for me in my react native app. but for implimenting the video pausing functionality i updated the package to latest and the blank screen isssue arises in som e device for example samsung galaxy note 5, redmi 11 pro + etc..
"react-native-vision-camera": "^3.6.10",
i will give some of the code in implimented there.
`const camera = useRef(null); useEffect(() => { requestCameraPermissions().then(hasPermission => { if (hasPermission) { setCameraPermission(true); } else { console.error('Permissions not granted'); // Handle lack of permissions appropriately } }); }, []);
async function requestCameraPermissions() { if (Platform.OS === 'android') { const cameraPermission = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.CAMERA, ); const microphonePermission = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.RECORD_AUDIO, ); return ( cameraPermission === PermissionsAndroid.RESULTS.GRANTED && microphonePermission === PermissionsAndroid.RESULTS.GRANTED ); } else { // For iOS, use react-native-vision-camera's requestCameraPermission method const cameraPermissionStatus = await Camera.requestCameraPermission(); const microphonePermissionStatus = await Camera.requestMicrophonePermission(); return ( cameraPermissionStatus === 'authorized' && microphonePermissionStatus === 'authorized' ); } } const cameraDevice = useCameraDevice('front'); const handleRecordVideo = async () => { if (camera.current) { try { console.log('camera.current.startRecording', camera.current); camera.current.startRecording({ flash: 'on', videoBitrate: 1000000, video: { codec: 'h264', frameRate: 30, }, onRecordingFinished: video => { setVideoPath(video.path); }, onRecordingError: error => console.error(error), }); startPlaying(); setRecordingStarted(true); } catch (e) { console.log(e); } } }; const toggleVideoPlaying = async () => { try { if (!paused) { await camera.current.pauseRecording(); await TrackPlayer.pause(); setPaused(true); } else { await camera.current.resumeRecording(); await TrackPlayer.play(); setPaused(false); } // setRecordingStarted(false); } catch (e) { console.log(e); } }; return (
What's happening?
I wan to use react native vision camera in my rn app, but in some devices it works very fine. but in some device iam getting device as null or undefiend, happening in older device and latest devices. i am getting different errors also.
Reproduceable Code
Relevant log output
Camera Device
Device
Samsung galaxy note 5, redmi 11 pro +5g
VisionCamera Version
3.6.10
Can you reproduce this issue in the VisionCamera Example app?
I didn't try (â ď¸ your issue might get ignored & closed if you don't try this)
Additional information