Skip to content

Commit

Permalink
fix(ios): pause scanning with pausePreview method on iOS
Browse files Browse the repository at this point in the history
While iOS can uniquely continue scanning without the preview being rendered, other platforms already

pause and resume scanning with the pausePreview and resumePreview methods, respectively. This makes

the iOS implementation match the others exactly.

Closes #12.
  • Loading branch information
bitjson committed Oct 1, 2016
1 parent ae01f32 commit c0722c7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ios/QRScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class QRScanner : CDVPlugin, AVCaptureMetadataOutputObjectsDelegate {
var backCamera: AVCaptureDevice?

var scanning: Bool = false
var paused: Bool = false;
var nextScanningCommand: CDVInvokedUrlCommand?

enum QRScannerError: Int32 {
Expand Down Expand Up @@ -258,11 +259,19 @@ class QRScanner : CDVPlugin, AVCaptureMetadataOutputObjectsDelegate {
}

func pausePreview(command: CDVInvokedUrlCommand) {
if(scanning){
paused = true;
scanning = false;
}
captureVideoPreviewLayer?.connection.enabled = false
self.getStatus(command)
}

func resumePreview(command: CDVInvokedUrlCommand) {
if(paused){
paused = false;
scanning = true;
}
captureVideoPreviewLayer?.connection.enabled = true
self.getStatus(command)
}
Expand Down

0 comments on commit c0722c7

Please sign in to comment.