mirror of
https://github.com/wahyd4/BarcodeScanner.git
synced 2026-08-09 21:15:54 +10:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12be23d657 | ||
|
|
12ecfd7f55 | ||
|
|
933525da37 | ||
|
|
7ad74807c3 | ||
|
|
7d831d83ed | ||
|
|
ec4de624ae |
@@ -10,6 +10,7 @@
|
|||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <AVFoundation/AVFoundation.h>
|
#import <AVFoundation/AVFoundation.h>
|
||||||
#import <AssetsLibrary/AssetsLibrary.h>
|
#import <AssetsLibrary/AssetsLibrary.h>
|
||||||
|
#import <AudioToolbox/AudioToolbox.h>
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// use the all-in-one version of zxing that we built
|
// use the all-in-one version of zxing that we built
|
||||||
@@ -205,6 +206,8 @@
|
|||||||
@synthesize is2D = _is2D;
|
@synthesize is2D = _is2D;
|
||||||
@synthesize capturing = _capturing;
|
@synthesize capturing = _capturing;
|
||||||
|
|
||||||
|
SystemSoundID _soundFileObject;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
- (id)initWithPlugin:(CDVBarcodeScanner*)plugin
|
- (id)initWithPlugin:(CDVBarcodeScanner*)plugin
|
||||||
callback:(NSString*)callback
|
callback:(NSString*)callback
|
||||||
@@ -222,6 +225,9 @@ parentViewController:(UIViewController*)parentViewController
|
|||||||
self.is2D = YES;
|
self.is2D = YES;
|
||||||
self.capturing = NO;
|
self.capturing = NO;
|
||||||
|
|
||||||
|
CFURLRef soundFileURLRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("CDVBarcodeScanner.bundle/beep"), CFSTR ("caf"), NULL);
|
||||||
|
AudioServicesCreateSystemSoundID(soundFileURLRef, &_soundFileObject);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,6 +243,9 @@ parentViewController:(UIViewController*)parentViewController
|
|||||||
|
|
||||||
self.capturing = NO;
|
self.capturing = NO;
|
||||||
|
|
||||||
|
AudioServicesRemoveSystemSoundCompletion(_soundFileObject);
|
||||||
|
AudioServicesDisposeSystemSoundID(_soundFileObject);
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,6 +290,9 @@ parentViewController:(UIViewController*)parentViewController
|
|||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
- (void)barcodeScanSucceeded:(NSString*)text format:(NSString*)format {
|
- (void)barcodeScanSucceeded:(NSString*)text format:(NSString*)format {
|
||||||
[self barcodeScanDone];
|
[self barcodeScanDone];
|
||||||
|
|
||||||
|
AudioServicesPlaySystemSound(_soundFileObject);
|
||||||
|
|
||||||
[self.plugin returnSuccess:text format:format cancelled:FALSE callback:self.callback];
|
[self.plugin returnSuccess:text format:format cancelled:FALSE callback:self.callback];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +332,9 @@ parentViewController:(UIViewController*)parentViewController
|
|||||||
output.alwaysDiscardsLateVideoFrames = YES;
|
output.alwaysDiscardsLateVideoFrames = YES;
|
||||||
output.videoSettings = videoOutputSettings;
|
output.videoSettings = videoOutputSettings;
|
||||||
|
|
||||||
[output setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
|
dispatch_queue_t queue = dispatch_queue_create("CDVBarcodeScanner", NULL);
|
||||||
|
[output setSampleBufferDelegate:self queue:queue];
|
||||||
|
dispatch_release(queue);
|
||||||
|
|
||||||
if (![captureSession canSetSessionPreset:AVCaptureSessionPresetMedium]) {
|
if (![captureSession canSetSessionPreset:AVCaptureSessionPresetMedium]) {
|
||||||
return @"unable to preset medium quality video capture";
|
return @"unable to preset medium quality video capture";
|
||||||
@@ -416,7 +430,13 @@ parentViewController:(UIViewController*)parentViewController
|
|||||||
const char* cString = resultText->getText().c_str();
|
const char* cString = resultText->getText().c_str();
|
||||||
NSString* resultString = [[[NSString alloc] initWithCString:cString encoding:NSUTF8StringEncoding] autorelease];
|
NSString* resultString = [[[NSString alloc] initWithCString:cString encoding:NSUTF8StringEncoding] autorelease];
|
||||||
|
|
||||||
[self barcodeScanSucceeded:resultString format:format];
|
NSMethodSignature *sig = [self methodSignatureForSelector:@selector(barcodeScanSucceeded:format:)];
|
||||||
|
NSInvocation *invoke = [NSInvocation invocationWithMethodSignature:sig];
|
||||||
|
[invoke setTarget:self];
|
||||||
|
[invoke setSelector:@selector(barcodeScanSucceeded:format:)];
|
||||||
|
[invoke setArgument:&resultString atIndex:2];
|
||||||
|
[invoke setArgument:&format atIndex:3];
|
||||||
|
[invoke performSelectorOnMainThread:@selector(invoke) withObject:nil waitUntilDone:YES];
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (zxing::ReaderException &rex) {
|
catch (zxing::ReaderException &rex) {
|
||||||
@@ -855,4 +875,4 @@ parentViewController:(UIViewController*)parentViewController
|
|||||||
[super willAnimateRotationToInterfaceOrientation:orientation duration:duration];
|
[super willAnimateRotationToInterfaceOrientation:orientation duration:duration];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
Reference in New Issue
Block a user