protected override void OnElementChanged(ElementChangedEventArgs <ScannerView> e) { base.OnElementChanged(e); FormsView = Element; if (PlatformView == null) { PlatformView = new CPSurfaceView(this.Context) { LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent) }; _cameraAnalyzer = PlatformView.CameraAnalyzer; PlatformView.SurfaceTextureAvailable += NativeSurface_SurfaceTextureAvailable; PlatformView.SurfaceTextureDestroyed += NativeSurface_SurfaceTextureDestroyed; PlatformView.SurfaceTextureSizeChanged += NativeSurface_SurfaceTextureSizeChanged; base.SetNativeControl(PlatformView); if (FormsView.IsScanning) { PlatformView.StartScanning(FormsView.RaiseScanResult, FormsView.Options); } if (!FormsView.IsAnalyzing) { PlatformView.PauseAnalysis(); } } }
private void Init() { if (_cameraAnalyzer == null) { _cameraAnalyzer = new CameraAnalyzer(this); } _cameraAnalyzer.ResumeAnalysis(); }
public void StartScanning(Action <IScanResult> scanResultCallback, ScanningOptionsBase options = null) { //fix Android 7 bug: camera freezes because surfacedestroyed function isn't always called correct, the old surfaceview was still visible. this.Visibility = ViewStates.Visible; CameraPreviewSettings.Instance.SetScannerOptions(options); CameraAnalyzer.ResultFound += (sender, result) => { scanResultCallback?.Invoke(result); }; CameraAnalyzer.ResumeAnalysis(); }
public void ResumeAnalysis() { CameraAnalyzer.ResumeAnalysis(); }
public void PauseAnalysis() { CameraAnalyzer.PauseAnalysis(); }
public void StopScanning() { CameraAnalyzer.ShutdownCamera(); //fix Android 7 bug: camera freezes because surfacedestroyed function isn't always called correct, the old surfaceview was still visible. this.Visibility = ViewStates.Gone; }