Last active
May 7, 2018 13:59
-
-
Save wullink-ps/6f24c01517c4da0a0dc4c905f16466c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task<string> GetResultAsync() | |
| { | |
| var scanner = new MobileBarcodeScanner(); | |
| Result result = await scanner.Scan(); | |
| RestoreCameraSettings(); | |
| return result?.Text; | |
| } | |
| private void RestoreCameraSettings() | |
| { | |
| var devices = AVCaptureDevice.DevicesWithMediaType(AVMediaType.Video); | |
| AVCaptureDevice captureDevice = null; | |
| foreach (var device in devices) | |
| { | |
| if (device.Position == AVCaptureDevicePosition.Back) | |
| { | |
| captureDevice = device; | |
| } | |
| } | |
| if (captureDevice == null) | |
| { | |
| return; | |
| } | |
| if (captureDevice.LockForConfiguration(out NSError err)) | |
| { | |
| if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0) && captureDevice.AutoFocusRangeRestrictionSupported) | |
| { | |
| captureDevice.AutoFocusRangeRestriction = AVCaptureAutoFocusRangeRestriction.None; | |
| } | |
| captureDevice.UnlockForConfiguration(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
isn't that a little bit of code violation to use the xamarin.ios in portable project.?