avcapturedevice

iOS: Torch level on iPhone 11 Pro

亡梦爱人 提交于 2020-06-10 09:59:19
问题 I'm using AVCaptureDevice.setTorchModeOn(level) method to turn on the flashlight at variable brightness. On my old iPhone SE it's working fine — I can clearly see 4 different brightness levels as I change level from 0 to 1 . But on the iPhone 11 Pro the flashlight turns on only when level is 1.0 ! And it's brightness if far from maximum level (compared to flashlight from Control Center). I tried using maxAvailableTorchLevel constant, but results are the same as using 1.0 . Also tried values

Why my iOS app does not ask user permission to access camera?

只愿长相守 提交于 2020-05-15 04:48:07
问题 I develop iOS app and it uses camera. AVCaptureDeviceInput is used to interface to camera. I checked Authorisation status as - (void)checkDeviceAuthorizationStatus { NSString *mediaType = AVMediaTypeVideo; [AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) { if (granted) { //Granted access to mediaType [self setDeviceAuthorized:YES]; } else { //Not granted access to mediaType dispatch_async(dispatch_get_main_queue(), ^{ [[[UIAlertView alloc] initWithTitle:@

iOS Record video with audio from a file

狂风中的少年 提交于 2020-02-07 03:34:47
问题 I am creating and app where I want the user to be able to record a video but have audio from a pre-recorded audio file. I have implemented the video capture and can even play the audio while recording, but I do not want the microphone on, I would like the audio to come from a file. I am currently adding the audio input device like so: let audioInputDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio) do { let audioInput = try AVCaptureDeviceInput(device: audioInputDevice) if

Swift isLockingFocusWithCustomLensPositionSupported always returns false

陌路散爱 提交于 2020-01-23 17:01:31
问题 I want to set the lens distance of my iPhoneX to a constant. In order to check if that is supported, I check the isLockingFocusWithCustomLensPositionSupported property of my device, as described in the documentation here: https://developer.apple.com/documentation/avfoundation/avcapturedevice/2361529-islockingfocuswithcustomlensposi The method always returns false, even when the device is locked for configuration, which means that calling the method setFocusModeLocked(lensPosition,

Swift isLockingFocusWithCustomLensPositionSupported always returns false

偶尔善良 提交于 2020-01-23 17:01:08
问题 I want to set the lens distance of my iPhoneX to a constant. In order to check if that is supported, I check the isLockingFocusWithCustomLensPositionSupported property of my device, as described in the documentation here: https://developer.apple.com/documentation/avfoundation/avcapturedevice/2361529-islockingfocuswithcustomlensposi The method always returns false, even when the device is locked for configuration, which means that calling the method setFocusModeLocked(lensPosition,

Swift isLockingFocusWithCustomLensPositionSupported always returns false

蹲街弑〆低调 提交于 2020-01-23 17:01:07
问题 I want to set the lens distance of my iPhoneX to a constant. In order to check if that is supported, I check the isLockingFocusWithCustomLensPositionSupported property of my device, as described in the documentation here: https://developer.apple.com/documentation/avfoundation/avcapturedevice/2361529-islockingfocuswithcustomlensposi The method always returns false, even when the device is locked for configuration, which means that calling the method setFocusModeLocked(lensPosition,

Preventing AVCaptureVideoPreviewLayer from rotating, but allow UI layer to rotate with orientation

大城市里の小女人 提交于 2020-01-20 03:34:31
问题 I have two view controllers. One is the root VC and contains the UI interface such as the record button. On this view controller, I also display the view of another VC at index 0. This view contains a AVCaptureVideoPreviewLayer. I would like my video camera to mimic the Apple video camera app, where the interface layout adjusts with the rotation, but the video preview layer does not. You can see how the recording timer (UILabel) in the stock video app disappears and reappears at the top

How do I implement camera changing from front to back camera

ε祈祈猫儿з 提交于 2020-01-06 06:37:33
问题 Below is the code for the camera section, I tried adding in a boolean to detect when the front camera is activated but I receive an error. import UIKit import AVFoundation class MainCameraCollectionViewCell: UICollectionViewCell { @IBOutlet weak var myView: UIView! var captureSession = AVCaptureSession() var backCamera: AVCaptureDevice? var frontCamera: AVCaptureDevice? var currentCamera: AVCaptureDevice? var photoOutPut: AVCapturePhotoOutput? var cameraPreviewLayer:

How do I implement camera changing from front to back camera

拟墨画扇 提交于 2020-01-06 06:36:27
问题 Below is the code for the camera section, I tried adding in a boolean to detect when the front camera is activated but I receive an error. import UIKit import AVFoundation class MainCameraCollectionViewCell: UICollectionViewCell { @IBOutlet weak var myView: UIView! var captureSession = AVCaptureSession() var backCamera: AVCaptureDevice? var frontCamera: AVCaptureDevice? var currentCamera: AVCaptureDevice? var photoOutPut: AVCapturePhotoOutput? var cameraPreviewLayer:

AVCaptureDevice videoZoomFactor always Out of Range

别说谁变了你拦得住时间么 提交于 2020-01-02 10:05:34
问题 I'm trying to set the zoom level of a camera by this code: AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; if ([videoDevice lockForConfiguration:nil]) { float newzoom=1.3; videoDevice.videoZoomFactor = newzoom; [videoDevice unlockForConfiguration]; } This code doesn't not works in ios 7(it works in ios 9), it cause always an exception: Terminating app due to uncaught exception 'NSRangeException', reason: 'videoZoomFactor out of range' I can't find