mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-20 13:48:21 +02:00
Improve camera reliability and diagnose capture issues more effectively
Adds detailed logging and retry logic to address camera startup and dimension detection failures in CameraModal and useCamera. Replit-Commit-Author: Agent Replit-Commit-Session-Id: dec54137-d5a2-4406-8ad4-5f2f9fb110bf Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/eb403944-9342-469a-8dd7-95b8b1a1cf40.jpg
This commit is contained in:
1 parent
ed38c25c9f
commit
97c6f3ec1e
3 files changed
+108
-14
No files matched your search
@@ -25,31 +25,47 @@ export default function CameraModal({
|
||||
}: CameraModalProps) {
|
||||
useEffect(() => {
|
||||
if (isOpen && videoRef.current) {
|
||||
// Ensure video starts playing when modal opens
|
||||
const video = videoRef.current;
|
||||
console.log('CameraModal useEffect - video element ready');
|
||||
|
||||
const handleLoadedMetadata = () => {
|
||||
console.log('Video loaded metadata:', video.videoWidth, 'x', video.videoHeight);
|
||||
console.log('CameraModal: Video metadata loaded, dimensions:', video.videoWidth, 'x', video.videoHeight);
|
||||
};
|
||||
|
||||
const handleCanPlay = () => {
|
||||
console.log('Video can play');
|
||||
console.log('CameraModal: Video can play, readyState:', video.readyState);
|
||||
};
|
||||
|
||||
const handleError = (error: Event) => {
|
||||
console.error('Video error:', error);
|
||||
console.error('CameraModal: Video error event:', error);
|
||||
};
|
||||
|
||||
const handlePlay = () => {
|
||||
console.log('CameraModal: Video started playing');
|
||||
};
|
||||
|
||||
video.addEventListener('loadedmetadata', handleLoadedMetadata);
|
||||
video.addEventListener('canplay', handleCanPlay);
|
||||
video.addEventListener('error', handleError);
|
||||
video.addEventListener('play', handlePlay);
|
||||
|
||||
video.play().catch(console.error);
|
||||
// Forcer le play avec gestion d'erreur
|
||||
const startPlayback = async () => {
|
||||
try {
|
||||
await video.play();
|
||||
console.log('CameraModal: Video play() successful');
|
||||
} catch (playError) {
|
||||
console.error('CameraModal: Video play() failed:', playError);
|
||||
}
|
||||
};
|
||||
|
||||
startPlayback();
|
||||
|
||||
return () => {
|
||||
video.removeEventListener('loadedmetadata', handleLoadedMetadata);
|
||||
video.removeEventListener('canplay', handleCanPlay);
|
||||
video.removeEventListener('error', handleError);
|
||||
video.removeEventListener('play', handlePlay);
|
||||
};
|
||||
}
|
||||
}, [isOpen, videoRef]);
|
||||
|
||||
Reference in new issue
Block a user