Commit f3e8f7a2 authored by cyqresig's avatar cyqresig

fixed the bug: cannot restart barcode scan session

parent b0d40d64
...@@ -52,9 +52,6 @@ ...@@ -52,9 +52,6 @@
{ {
// NSLog(@"removeFromSuperview..."); // NSLog(@"removeFromSuperview...");
[self.scanLineTimer invalidate];
self.scanLineTimer = nil;
[self.manager endSession]; [self.manager endSession];
[super removeFromSuperview]; [super removeFromSuperview];
} }
......
...@@ -61,6 +61,9 @@ RCT_CUSTOM_VIEW_PROPERTY(barCodeTypes, NSArray, RCTBarcode) { ...@@ -61,6 +61,9 @@ RCT_CUSTOM_VIEW_PROPERTY(barCodeTypes, NSArray, RCTBarcode) {
} }
- (void)initializeCaptureSessionInput:(NSString *)type { - (void)initializeCaptureSessionInput:(NSString *)type {
NSLog(@"initializeCaptureSessionInput...");
dispatch_async(self.sessionQueue, ^{ dispatch_async(self.sessionQueue, ^{
[self.session beginConfiguration]; [self.session beginConfiguration];
...@@ -84,6 +87,9 @@ RCT_CUSTOM_VIEW_PROPERTY(barCodeTypes, NSArray, RCTBarcode) { ...@@ -84,6 +87,9 @@ RCT_CUSTOM_VIEW_PROPERTY(barCodeTypes, NSArray, RCTBarcode) {
if ([self.session canAddInput:captureDeviceInput]) { if ([self.session canAddInput:captureDeviceInput]) {
NSLog(@"self.session canAddInput:captureDeviceInput...");
[self.session addInput:captureDeviceInput]; [self.session addInput:captureDeviceInput];
self.videoCaptureDeviceInput = captureDeviceInput; self.videoCaptureDeviceInput = captureDeviceInput;
...@@ -107,6 +113,9 @@ RCT_EXPORT_METHOD(startSession) { ...@@ -107,6 +113,9 @@ RCT_EXPORT_METHOD(startSession) {
// NSLog(@"self.metadataOutput = %@", self.metadataOutput); // NSLog(@"self.metadataOutput = %@", self.metadataOutput);
if(self.metadataOutput == nil) { if(self.metadataOutput == nil) {
NSLog(@"self.metadataOutput = %@", self.metadataOutput);
AVCaptureMetadataOutput *metadataOutput = [[AVCaptureMetadataOutput alloc] init]; AVCaptureMetadataOutput *metadataOutput = [[AVCaptureMetadataOutput alloc] init];
self.metadataOutput = metadataOutput; self.metadataOutput = metadataOutput;
...@@ -171,6 +180,7 @@ RCT_EXPORT_METHOD(stopSession) { ...@@ -171,6 +180,7 @@ RCT_EXPORT_METHOD(stopSession) {
[self.session commitConfiguration]; [self.session commitConfiguration];
[self.session stopRunning]; [self.session stopRunning];
[self.barcode.scanLineTimer invalidate]; [self.barcode.scanLineTimer invalidate];
self.barcode.scanLineTimer = nil;
for(AVCaptureInput *input in self.session.inputs) { for(AVCaptureInput *input in self.session.inputs) {
[self.session removeInput:input]; [self.session removeInput:input];
} }
...@@ -178,6 +188,7 @@ RCT_EXPORT_METHOD(stopSession) { ...@@ -178,6 +188,7 @@ RCT_EXPORT_METHOD(stopSession) {
for(AVCaptureOutput *output in self.session.outputs) { for(AVCaptureOutput *output in self.session.outputs) {
[self.session removeOutput:output]; [self.session removeOutput:output];
} }
self.metadataOutput = nil;
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment