I can snap a picture with the iPhone programmatically by calling [UIImagePickerController takePicture:], but when I do the iPhone plays a loud recording of a shutter click. When I google for how to turn off the click, I find advice to rename the sound file that the iPhone plays. It seems to me for my app to do that would lead to it being rejected from the App store for accessing system frameworks. Is there a programmatic way to shut off that sound? The nature of my app demands that the camera be silent.
For what it's worth, I was able to get this to work by using this code in the snapStillImage method of AVCapture framework using AVCaptureStillImageOutput. It works perfectly for me on iOS 8.3 iPhone 5. I have also confirmed that Apple won't reject your app if you use this:
MPVolumeView* volumeView = [[MPVolumeView alloc] init];
//find the volumeSlider
UISlider* volumeViewSlider = nil;
for (UIView *view in [volumeView subviews]){
if ([view.class.description isEqualToString:@"MPVolumeSlider"]){
volumeViewSlider = (UISlider*)view;
break;
}
}
[volumeViewSlider setValue:0.0f animated:YES];
[volumeViewSlider sendActionsForControlEvents:UIControlEventTouchUpInside];
Swift 4:
var volumeView = MPVolumeView()
//find the volumeSlider
var volumeViewSlider: UISlider? = nil
for view: UIView in volumeView.subviews {
if (view.self.description == "MPVolumeSlider") {
volumeViewSlider = view as? UISlider
break
}
}
volumeViewSlider?.setValue(0.0, animated: true)
volumeViewSlider?.sendActions(for: .touchUpInside)
I assume you have solved it since but your app supposed to fail on the Appstore validation as it doesn't comply with iOS Dev License agreement. See below:
Section 3.3.8: Any form of user or device data collection, or image, picture or voice capture or recording (collectively "Recordings"), and any form of data, content or information collection, processing, maintenance, uploading, syncing, storage, transmission, sharing, disclosure or use performed by, through or in connection with Your Application must comply with all applicable privacy laws and regulations as well as any related Program Requirements, including but not limited to any notice or consent requirements. In particular, a reasonably conspicuous audio, visual or other indicator must be displayed to the user as part of the Application to indicate that a Recording is taking place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With