diff --git a/Areas/Inventory/Views/ItemMovement/QrUser.cshtml b/Areas/Inventory/Views/ItemMovement/QrUser.cshtml index 0f7cc84..dac81b6 100644 --- a/Areas/Inventory/Views/ItemMovement/QrUser.cshtml +++ b/Areas/Inventory/Views/ItemMovement/QrUser.cshtml @@ -375,7 +375,15 @@ qrCodeResult: null, debounceTimeout: null, error: "", - selectedConstraints: { facingMode: "environment" }, + selectedConstraints: { + video: { + facingMode: "environment", // Kamera belakang + width: { ideal: 1920 }, // Resolusi tinggi + height: { ideal: 1080 }, + focusMode: "continuous", // Auto-focus + zoom: 2.0 + } + }, trackFunctionSelected: { text: 'outline', value: null }, barcodeFormats: { qr_code: true, // Hanya mendukung QR Code @@ -625,28 +633,38 @@ } this.error = message; }, - //Setting Camera async onCameraReady() { - try { - const devices = await navigator.mediaDevices.enumerateDevices(); - this.videoInputDevices = devices.filter(device => device.kind === 'videoinput'); - - if (this.videoInputDevices.length > 0) { - // Keep the selected camera if already chosen - if (!this.selectedCameraId) { - this.selectedCameraId = this.videoInputDevices[0].deviceId; - } - - this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } }; - } else { - this.error = "No camera detected."; - } - } catch (err) { - this.error = "Error accessing camera: " + err.message; - } + this.enableAutoFocus(); }, + async enableAutoFocus() { + const devices = await navigator.mediaDevices.enumerateDevices(); + this.videoInputDevices = devices.filter(device => device.kind === 'videoinput'); + + if (this.videoInputDevices.length > 0) { + // Keep the selected camera if already chosen + if (!this.selectedCameraId) { + this.selectedCameraId = this.videoInputDevices[0].deviceId; + } + + this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } }; + } else { + this.error = "No camera detected."; + } + + + const stream = await navigator.mediaDevices.getUserMedia({ video: true }); + const track = stream.getVideoTracks()[0]; + const capabilities = track.getCapabilities(); + + if(capabilities.focusMode) { + await track.applyConstraints({ focusMode: "continuous" }); // Auto-focus + } + + }, + + //Update Camera Category updateCamera() { this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } }; diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index c2a3498..0035917 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -13,7 +13,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "http://localhost:5124", + "applicationUrl": "http://192.168.0.20:5124", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -22,7 +22,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "https://localhost:7036;http://localhost:5124", + "applicationUrl": "https://192.168.0.20:7036;http://192.168.0.20:5124", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }