Open YousefMohammed0060 opened 2 years ago
Hi, when you create the codeScanner variable of type CodeScanner you can set the CAMERA_BACK or CAMERA_FRONT, like this:
private fun codeScanner() {
codeScanner = CodeScanner(this, scannerView)
codeScanner.apply {
// camera = CodeScanner.CAMERA_BACK // uses phone main camera
camera = CodeScanner.CAMERA_FRONT // uses phone front camera
formats = CodeScanner.ALL_FORMATS // supports all code formats available in the library
autoFocusMode = AutoFocusMode.SAFE
// scanMode = ScanMode.CONTINUOUS // keeps decoding codes until told otherwise via a button or some action
scanMode = ScanMode.SINGLE // decodes the first code found and returns
isAutoFocusEnabled = true // enables auto focus mode as default
isFlashEnabled = false // false means flash light is off, true means it is on
}
}
hope this helps!
in java project it's not working. i also try to change camera but not working. i don't know in kotlin project work or not. i working on android 10 version.
You can use camera ID like codeScanner.setCamera(1);
but you have to do it by onclick inside a button or icon
How to make the scan made by the front camera not the main camera.