Author SHA1 Message Date
junv 12be23d657 update version 2014-02-10 10:03:27 +08:00
junv 12ecfd7f55 update version 2014-02-10 09:54:20 +08:00
junv 933525da37 try to fix issue 2014-02-10 09:51:30 +08:00
junv 7ad74807c3 Merge remote-tracking branch 'origin/huserben-master' 2014-02-08 16:08:35 +08:00
Jakob Gillich 7d831d83ed window.plugins is not defined anymore, replaced it with cordova.plugins
Reproduced in 3.1, see #60
2013-10-30 16:53:40 +01:00
Andrew Grieve ec4de624ae Add missing iOS framework "QuartzCore" to plugin.xml 2013-10-03 15:11:25 -04:00
+23 -3
View File
@@ -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