{"action":"opened","issue":{"url":"https://api.github.com/repos/mikebuss/MTBBarcodeScanner/issues/43","labels_url":"https://api.github.com/repos/mikebuss/MTBBarcodeScanner/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/mikebuss/MTBBarcodeScanner/issues/43/comments","events_url":"https://api.github.com/repos/mikebuss/MTBBarcodeScanner/issues/43/events","html_url":"https://github.com/mikebuss/MTBBarcodeScanner/issues/43","id":107166063,"number":43,"title":"Get notified when camera starts scanning.","user":{"login":"jaybowong","id":1948533,"avatar_url":"https://avatars.githubusercontent.com/u/1948533?v=3","gravatar_id":"","url":"https://api.github.com/users/jaybowong","html_url":"https://github.com/jaybowong","followers_url":"https://api.github.com/users/jaybowong/followers","following_url":"https://api.github.com/users/jaybowong/following{/other_user}","gists_url":"https://api.github.com/users/jaybowong/gists{/gist_id}","starred_url":"https://api.github.com/users/jaybowong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaybowong/subscriptions","organizations_url":"https://api.github.com/users/jaybowong/orgs","repos_url":"https://api.github.com/users/jaybowong/repos","events_url":"https://api.github.com/users/jaybowong/events{/privacy}","received_events_url":"https://api.github.com/users/jaybowong/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-18T09:27:04Z","updated_at":"2015-09-18T09:27:04Z","closed_at":null,"body":"![2](https://cloud.githubusercontent.com/assets/1948533/9955720/de7642e4-5e25-11e5-91a6-85c441d2139b.png)\r\n---\r\n`startScanningWithResultBlock` takes a while to get camera ready to use especially when it comes to a full screen preview view. I want to show a preparing indicator UIActivityIndicatorView before call `startScanningWithResultBlock` and get notified when the camera is ready and shown to use so I can stop animating that indicator. This user experience is better if there's a loading indicator while waiting.\r\n\r\nThe following lines of code is just preparing the camera but it takes enough time to make users wait.\r\n```objc\r\n    if (!self.hasExistingSession) {\r\n        AVCaptureDevice *captureDevice = [self newCaptureDeviceWithCamera:self.camera];\r\n        self.session = [self newSessionWithCaptureDevice:captureDevice];\r\n        self.hasExistingSession = YES;\r\n    }\r\n    \r\n    [self.session startRunning];\r\n```\r\n\r\nInstruments shows this.\r\n![3](https://cloud.githubusercontent.com/assets/1948533/9956022/e378490c-5e27-11e5-94c7-99f831a2fcf6.png)\r\nI don't know how to translate that **22.0ms** CPU time into real time but it indeed made me wait.\r\n\r\n--\r\nSince there's no delegate in MTBBarcodeScanner, I'm thinking about adding a block property in the header file.\r\n`@property (nonatomic, copy) void (^didStartScanningBlock)();`\r\nAnd call this block in MTBBarcodeScanner like below.\r\n```objc\r\n- (void)startScanningWithResultBlock:(void (^)(NSArray *codes))resultBlock {\r\n    // ...\r\n    \r\n    [self.session startRunning];\r\n    // ...\r\n\r\n    // Last three line\r\n    if (self.didStartScanningBlock) {\r\n        self.didStartScanningBlock();\r\n    }\r\n}\r\n```\r\n\r\n----\r\nWhat do you guys think?"}}