diff --git a/resources/views/fields/camera-capture.blade.php b/resources/views/fields/camera-capture.blade.php index 5051b16..23148fe 100644 --- a/resources/views/fields/camera-capture.blade.php +++ b/resources/views/fields/camera-capture.blade.php @@ -185,20 +185,35 @@ document.addEventListener('DOMContentLoaded', () => { photoTaken: false, photo1: '', + // async initCamera() { + // try { + // if (this.stream) this.stream.getTracks().forEach(track => track.stop()); + + // this.stream = await navigator.mediaDevices.getUserMedia({ + // video: { facingMode: this.currentFacingMode } + // }); + + // this.$refs.video.srcObject = this.stream; + // } catch (err) { + // console.error("Camera error:", err); + // alert("Cannot access camera. Enable permissions or use HTTPS."); + // } + // }, async initCamera() { try { - if (this.stream) this.stream.getTracks().forEach(track => track.stop()); - this.stream = await navigator.mediaDevices.getUserMedia({ - video: { facingMode: this.currentFacingMode } + video: { + width: { ideal: 1920 }, + height: { ideal: 1080 }, + }, + audio: false }); - this.$refs.video.srcObject = this.stream; } catch (err) { - console.error("Camera error:", err); - alert("Cannot access camera. Enable permissions or use HTTPS."); + console.error('Error accessing camera:', err); } - }, + } + async switchCamera() { this.currentFacingMode = this.currentFacingMode === 'user' ? 'environment' : 'user';