[英]Xamarin Forms - Zxing QR Scanner - How can you toggle the camera being used?
When I start scanning for barcodes using a ScannerView
in Xamarian
forms, it automatically goes to the back camera on the phone. 当我开始使用Xamarian
形式的ScannerView
扫描条形码时,它会自动转到手机的后置摄像头。
I would like to make a toggle camera button that toggles the camera from back to front and vice versa. 我想制作一个切换相机按钮,将相机从后切换到前,反之亦然。
Is this possible using zxing for xamarin forms? 使用xxing形式的xamarin可以做到吗?
My options look like this: 我的选择如下所示:
code: 码:
//Set the scanner options.
ScannerView.Options = new ZXing.Mobile.MobileBarcodeScanningOptions()
{
UseNativeScanning = true,
AutoRotate = true,
PossibleFormats = new List<ZXing.BarcodeFormat>()
{
ZXing.BarcodeFormat.QR_CODE
},
TryHarder = true,
UseFrontCameraIfAvailable = false,
DelayBetweenContinuousScans = 2000
};
Once I start scanning by setting 一旦我通过设置开始扫描
ScannerView.IsScanning = true;
Setting: 设置:
ScannerView.Options.UseFrontCameraIfAvailable = true;
Does NOT change the camera. 请勿更换相机。 I can however do this 但是我可以这样做
ScannerView = null;
CreateScannerView();
ScannerView.Options.UseFrontCameraIfAvailable = true;
ScannerView.IsScanning = true;
And it works. 而且有效。 However the camera view completely disappears for about 2 seconds and then comes back. 但是,摄像机视图会完全消失约2秒钟,然后返回。 When I did it native Xcode
for iOS
for another app, the camera view never went away and just flipped cameras. 当我为另一个应用程序为iOS
使用本机Xcode
,相机视图永不消失,只是翻转了相机。 I'm expecting something like that. 我期待这样的事情。
Is switching the camera possible? 可以切换相机吗?
I don't think switching between cameras itself is possible with Zxing once it has started scanning so the option has to be chosen and set beforehand. 我不认为Zxing一旦开始扫描就无法在相机之间进行切换,因此必须事先选择并设置选项。
var options = new MobileBarcodeScanningOptions
{
AutoRotate = true,
UseNativeScanning = true,
TryHarder = true,
TryInverted = true,
UseFrontCameraIfAvailable = true
};
var scannedCode = await _scanner.Scan(options);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.