From a406a174d39b298a0744b6c38d197106667629c2 Mon Sep 17 00:00:00 2001 From: Angel Cortez Date: Wed, 26 Oct 2016 11:32:28 -0400 Subject: [PATCH] Added mic permissions to project --- .../TGCameraNavigationController.swift | 20 ++++++++++++++++--- .../Classes/Helper/TGCamera.swift | 2 ++ .../en.lproj/Localizable.strings | 6 +++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/TGCameraViewController/Classes/Control/TGCameraNavigationController.swift b/TGCameraViewController/Classes/Control/TGCameraNavigationController.swift index 3292537..d0d7e7c 100644 --- a/TGCameraViewController/Classes/Control/TGCameraNavigationController.swift +++ b/TGCameraViewController/Classes/Control/TGCameraNavigationController.swift @@ -36,15 +36,29 @@ open class TGCameraNavigationController: UINavigationController { let navigationController: TGCameraNavigationController = TGCameraNavigationController() navigationController.isNavigationBarHidden = true //if navigationController != nil { - let status: AVAuthorizationStatus = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) - switch status { + let cameraStatus: AVAuthorizationStatus = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) + let micStatus: AVAuthorizationStatus = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeAudio) + /*switch status { case .authorized: navigationController.setupAuthorizedWithDelegate(delegate) case .restricted, .denied: navigationController.setupDenied() case .notDetermined: navigationController.setupNotDeterminedWithDelegate(delegate) - } + }*/ + + if cameraStatus == .authorized && micStatus == .authorized + { + navigationController.setupAuthorizedWithDelegate(delegate) + } + else if cameraStatus == .restricted || cameraStatus == .denied && micStatus == .restricted || micStatus == .denied + { + navigationController.setupDenied() + } + else + { + navigationController.setupNotDeterminedWithDelegate(delegate) + } // } return navigationController diff --git a/TGCameraViewController/Classes/Helper/TGCamera.swift b/TGCameraViewController/Classes/Helper/TGCamera.swift index 561cccb..e93cb89 100644 --- a/TGCameraViewController/Classes/Helper/TGCamera.swift +++ b/TGCameraViewController/Classes/Helper/TGCamera.swift @@ -173,6 +173,7 @@ open class TGCamera: NSObject, AVCaptureFileOutputRecordingDelegate{ self.session.automaticallyConfiguresApplicationAudioSession = false self.session.usesApplicationAudioSession = true + // // setup device // @@ -190,6 +191,7 @@ open class TGCamera: NSObject, AVCaptureFileOutputRecordingDelegate{ } device.exposureMode = .continuousAutoExposure + if TGCamera.minDuration != CMTimeMake(0, 0) { device.activeVideoMinFrameDuration = TGCamera.minDuration diff --git a/TGCameraViewController/Resources/TGCameraViewController.bundle/en.lproj/Localizable.strings b/TGCameraViewController/Resources/TGCameraViewController.bundle/en.lproj/Localizable.strings index 61bdb0d..fcfc089 100644 --- a/TGCameraViewController/Resources/TGCameraViewController.bundle/en.lproj/Localizable.strings +++ b/TGCameraViewController/Resources/TGCameraViewController.bundle/en.lproj/Localizable.strings @@ -6,9 +6,9 @@ Copyright (c) 2015 Tudo Gostoso Internet. All rights reserved. */ -"TGCameraViewController-Title" = "Take photos"; +"TGCameraViewController-Title" = "Take photos and video"; "TGCameraViewController-Subtitle" = "Allow access to your camera to start taking pictures with app"; "TGCameraViewController-Step1" = "1. Open the Settings of your device"; "TGCameraViewController-Step2" = "2. Go to Privacy"; -"TGCameraViewController-Step3" = "3. Go the Camera"; -"TGCameraViewController-Step4" = "4. Activate"; \ No newline at end of file +"TGCameraViewController-Step3" = "3. Go to Camera and Activate"; +"TGCameraViewController-Step4" = "4. Go to Microphone and Activate";